相关疑难解决方法(0)

在Dapper中正确使用Multimapping

我正在尝试使用dapper的Multimapping功能来返回ProductItems和相关Customers的列表.

[Table("Product")]
public class ProductItem
{
    public decimal ProductID { get; set; }        
    public string ProductName { get; set; }
    public string AccountOpened { get; set; }
    public Customer Customer { get; set; }
} 

public class Customer
{
    public decimal CustomerId { get; set; }
    public string CustomerName { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

我的短小精悍的代码如下

var sql = @"select * from Product p 
            inner join Customer c on p.CustomerId = c.CustomerId 
            order by p.ProductName";

var data = con.Query<ProductItem, Customer, ProductItem>( …
Run Code Online (Sandbox Code Playgroud)

dapper

98
推荐指数
4
解决办法
7万
查看次数

标签 统计

dapper ×1