Last post Sep 20, 2019 02:33 AM by jiadongm
Sep 19, 2019 04:15 AM|vinodkpasi|LINK
Does ToList() method affect the Entity Framework Lazy/Eager/Explicit Loading?
Sep 19, 2019 08:37 AM|PatriceSc|LINK
Something like var query=db.Items.Where(o=>o.Name.StartsWith("A")); just defines a query but doesn't run it. The query will run the first time you iterate on data using foreach or ToList...
(if familiar with ADO.NET it could be compared with creating a SqlCommand and later executing this SqlCommand).
So yes ToList is often used when you want to explicitely load data at this point rather than having the query being triggered later at the UI level for example...
Sep 20, 2019 02:33 AM|jiadongm|LINK
As PatriceSc said, It is during the ToList() call when the query will actually be immediately executed. You can refer to
Query Execution for further understanding.