-
Notifications
You must be signed in to change notification settings - Fork 302
Multiple Result Sets
Stuart Attenborrow edited this page Jun 1, 2018
·
7 revisions
This feature enables you to map multiple queries with only one call to the database. The FetchMultiple
method returns a Tuple<List<T>, List<T1>>
.
Support: This is only supported on databases which can return multiple result sets, eg. NextResult()
on IDataReader
is implemented. Sql Server and Postgresql via Npgsql support this.
IDatabase db = new Database("connStringName");
Tuple<List<User>, List<Address>> data = db.FetchMultiple<User, Address>("select * from users;select * from addresses;");
var users = data.Item1;
var addresses = data.Item2;
This can be further simplified using C# 7 syntax for deconstructing tuples:
IDatabase db = new Database("connStringName");
var (users, addresses) = db.FetchMultiple<User, Address>("select * from users;select * from addresses;");