使用 Dapper 映射非原始对象

Mapping an non-primitive object with Dapper

我有以下class

    public class Point
    {
        public long Id { get; set; }

        public Address Address { get; set; }
    }

我正在尝试让 Dapper 正确映射地址数据。

   var points = this._db.Query<Point>("select * from Points").ToList();

我的table架构如下:

有什么方法可以指定特定的列数据给Dapper,以便映射非原始对象吗?

为了正确映射您需要使用多地图功能。

 var points = this._db.Query<Point, Address, Point>("select p.Id, 'x' [Id], p.Address_City [City], p.Address_State [State] from Points p", (p, a) =>
            {
                p.Address = a;
                return p;
            }).ToList();