读完这个问题后,我需要澄清一些事情。
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 子句并仅返回相关行 - 而第二个查询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;
现在执行会有什么不同?