Dapper 能否将数据直接返回到只有字段子集的 DTO/POCO 中 - 即我可以使用不包含 db 表中所有列的类吗?
例如,如果我有以下查询(请原谅我的 sql - 不是我的强项):
select c.Name as "Customer", o.Number as "OrderNo", ol.Number as "Line", p.Description as "Product", ol.Qty
from order o
join customer c on c.Id = o.CustomerId
join orderLine ol on ol.OrderID = o.Id
join product p on p.Id = ol.ProductId
where o.date >= 1/9/2013 and o.date <= 30/9/2013
如何使用 Dapper 将其读入以下类的数组/IEnumerable:
class CustOrders{
string Customer {get;set;}
integer Order {get;set;}
string Line {get;set;}
string Product {get;set;}
integer Qty {get; set;}
}
谢谢蒂姆