Linq和编译的查询
这是我的代码:
我需要将属性a.Valu
e的值与Literal.Text
属性相关联。
知道怎么做吗? 感谢您的宝贵帮助!
using (var context = new CmsConnectionStringEntityDataModel())
{
context.CmsOptions.MergeOption = MergeOption.NoTracking;
var query = CompiledQuery.Compile<CmsConnectionStringEntityDataModel, IQueryable<CmsOption>>
(ctx => from a in ctx.CmsOptions where a.OptionId == 7 select a);
uxHeaderIncluder.Text = // What I do here?;
}
答案 0 :(得分:0)
您是否看过以下示例: http://www.blog.ingenuitynow.net/15+Minutes+On+LINQ+Compiled+Queries.aspx http://msdn.microsoft.com/en-us/library/bb896297.aspx
该方法的核心是在Compile方法调用中指定输入类型。 您的编译调用应该是这样的:
CompiledQuery.Compile<CmsConnectionStringEntityDataModel,string,string, IQueryable<CmsOption>>
((ctx,str1,str2)=>from a in ctx.CmsOptions where a.OptionId == 7 && /* use str1 and str2 params here */ select a);