1
在Dapper文檔中,我可以清楚地看到半簡單對象或簡單對象的多重映射。例如:Dapper多重映射
public class Post
{
public int Id { get; set; }
public string Name { get; set; }
public User Owner { get; set; }
}
public class User
{
public int Id { get; set; }
public string Name { get; set; }
}
IDbConnection.QueryAsync<Post, User, Post>(query, (post, user) => { post.Owner = user; return post; }, new { Id = id }, null, true, "id", CommandType.Text);
問題是如何使Dapper處理具有多個內部對象的更復雜的對象。例如:
public class PlotStemDomain
{
public int Id { get; set; }
...
public PlotDomain Plot { get; set; }
public SpeciesDomain species { get; set; }
}
public class PlotDomain
{
public int Id { get; set; }
...
}
public class SpeciesDomain
{
public int Id { get; set; }
...
}
當它似乎只處理一個單一的Func<Post, User, Post>
。