Does it load all records in this code or uses something like SqlDataReader?
using (var c = new SqlConnection(_options.TargetConnectionString))
{
c.Open();
foreach(var record in c.Query("select * from Users")) // suppose N+1 records
{
// all records loaded or read one by one here?
// some work here...
}
}
Both options are supported. By default, the data is buffered into a List<T>
on the basis that most queries are fairly small, and to avoid the "multiple recordsets" limitation. To obtain the underlying list without an extra allocation, use the provided .AsList()
extension method. If, however, you want unbuffered data: pass buffered: false
. This will give you an enumerator that wraps the raw IDataReader
- suitable for huge queries.