splitOn具有重复模型属性的dapper.net映射

splitOn具有重复模型属性的dapper.net映射,.net,mapping,duplicates,dapper,.net,Mapping,Duplicates,Dapper,我有两个模型,其属性名称与 Class Office<br> { int Id; string Name; Location Location; } Class Location { int Id; string Name; } sqlConnection.Query<Office, Location, Office>("query", (o, l) => {o.Location=l}, splitOn="Id,Id").ToLis

我有两个模型,其属性名称与

Class Office<br>
{
   int Id;
   string Name;
   Location Location;
}

Class Location
{
   int Id;
   string Name;
}

sqlConnection.Query<Office, Location, Office>("query", (o, l) => {o.Location=l}, splitOn="Id,Id").ToList();
班级办公室
{ int-Id; 字符串名; 位置; } 类位置 { int-Id; 字符串名; } Query(“Query”,(o,l)=>{o.Location=l},splitOn=“Id,Id”).ToList();
我怎样才能使它工作


非常感谢您的帮助。

好吧,您只是忘记了在委托中返回新对象

(o, l) => {o.Location=l; return o;}
i、 e.你应该写:

sqlConnection.Query<Office, Location, Office>("query", (o, l) => {o.Location=l; return o;}, splitOn="Id,Id").ToList();
sqlConnection.Query(“Query”,(o,l)=>{o.Location=l;return o;},splitOn=“Id,Id”).ToList();