Dapper.NET 基本多个结果示例
示例
要在单个查询中获取多个网格,请使用该QueryMultiple方法。然后,您可以通过对返回的连续调用顺序检索每个网格GridReader。
var sql = @"select * from Customers where CustomerId = @id select * from Orders where CustomerId = @id select * from Returns where CustomerId = @id"; using (var multi = connection.QueryMultiple(sql, new {id=selectedId})) { var customer = multi.Read<Customer>().Single(); var orders = multi.Read<Order>().ToList(); var returns = multi.Read<Return>().ToList(); }