结果多结果
2019-04-11 17:33 更新
描述
QueryMultiple是一个扩展方法,可以从IDbConnection类型的任意对象中调用。它可以在同一命令中执行多个查询并映射结果。
+
string sql = "SELECT * FROM Invoice WHERE InvoiceID = @InvoiceID; SELECT * FROM InvoiceItem WHERE InvoiceID = @InvoiceID;";
using (var connection = My.ConnectionFactory())
{
connection.Open();
using (var multi = connection.QueryMultiple(sql, new {InvoiceID = 1}))
{
var invoice = multi.Read<Invoice>().First();
var invoiceItems = multi.Read<InvoiceItem>().ToList();
}
}
以上内容是否对您有帮助:
← 结果多映射
更多建议: