【发布时间】:2009-09-18 15:52:28
【问题描述】:
好的,我需要在这里进行健全性检查...
我编译了一个在执行时返回 IQueryable 的查询。
在以下示例中,查询应在哪一行实际对数据库执行?
101 IQueryable<T> results = MyCompiledQuery(MyDataContext);
102 List<T> final = (from t in result
103 where t.ID > 5
104 select t).ToList<T>();
这是我如何定义编译后的查询
public static Func<MyDataContext, IQueryable<Widget>> MyCompiledQuery=
CompiledQuery.Compile<MyDataContext, IQueryable<Widget>>(
(MyDataContext db) =>
from w in db.Widgets
where ((w.Type == WidgetType.Atype || //Widget.Atype is a Linq to Sql object, that I've defined statically
w.Type == WidgetType.Btype || //See above comment
w.Type == WidgetType.Ctype ) && //See above comment
w.Location == WidgetLocation.Domestic) //Samething applies here
select euc);
【问题讨论】:
标签: c# .net linq-to-sql