When does Dapper's'materialization' occur? At ToList, a Like Entity appears ()

dapper entity-framework orm

Question

The title pretty much says it all. Since Dapper does not have much documentation. Thanks in advance.

1
0
1/31/2017 10:18:31 AM

Popular Answer

Query() returns IEnumerable. When you start to iterate over your IEnumerable, inside Dapper some method is called with Yield to fill a POCO with a line of results, so your results are materialized progressively as you iterate over them. You need to keep the DB connection open as you do this, because you're not guaranteed that all lines of the result set come back at once. Indeed for large result sets, you want to be able to loop through them without ever having the whole result set in memory in the app. At any point, you can call ToList() on your IEnumerable, and then you've materialized everything, and you can close your connection.

2
1/31/2017 5:43:23 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow