IEnumerable <T> i IQueryable <T> wyjaśnienie?
Po przeczytaniuto pytanie, muszę wyjaśnić pewne rzeczy.
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;
Pytania:
1) Czy można powiedzieć, że: w pierwszym zapytaniu SQLServer uruchamia całą operację, w tym gdzie klauzula i zwracanieTYLKO odpowiednie wiersze - podczas gdy drugiSELECT *
... i wracawszystko wiersze w C # iNASTĘPNIE filtry?
2) A co jeśli mamkolekcja tylko - w pamięci. (var lstMyPerson = new List<MyPerson>()
)
IQueryable<MyPerson> lst = from c in lstMyPerson
where c.City == "<City>"
select c;
vs
IEnumerable<MyPerson> custs = from c in lstMyPerson
where c.City == "<City>"
select c;
jaka będzie teraz różnica w wykonaniu?