【发布时间】:2012-06-23 09:02:17
【问题描述】:
看完this的问题, 我需要澄清一些事情。
IQueryable<Customer> custs = from c in db.Customers
where c.City == "<City>"
select c;
IEnumerable<Customer> custs = from c in db.Customers
where c.City == "<City>"
select c;
问题:
1) 可以这样说:在第一个查询中,SQLServer 正在运行整个操作,包括 where 子句并返回 ONLY 相关行 - 而第二个查询则执行 SELECT * .. . 并将 所有 行返回到 C# 和 THEN 过滤器中?
2) 如果我只有一个 集合 - 在内存中怎么办。 (var lstMyPerson = new List<MyPerson>())
IQueryable<MyPerson> lst = from c in lstMyPerson
where c.City == "<City>"
select c;
对
IEnumerable<MyPerson> custs = from c in lstMyPerson
where c.City == "<City>"
select c;
现在执行会有什么不同?
【问题讨论】:
-
看看这个相关主题:stackoverflow.com/questions/252785/…。而且,您在#1中的假设是正确的。不是 100% 确定 #2,所以我会把它留给另一个人。
-
@blizz 我已经读过了。所有答案都来自一本书 POV。那里没有回答我的问题.... :(...我会很高兴看看哪一行回答了我的问题
标签: c# .net ienumerable iqueryable