相关疑难解决方法(0)

如何通过AutoMapper将匿名对象映射到类?

我有一个实体:

public class Tag {
    public int Id { get; set; }
    public string Word { get; set; }
    // other properties...
    // and a collection of blogposts:
    public ICollection<Post> Posts { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

和模型:

public class TagModel {
    public int Id { get; set; }
    public string Word { get; set; }
    // other properties...
    // and a collection of blogposts:
    public int PostsCount { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

我查询这样的实体(通过EFNH):

var tagsAnon = …
Run Code Online (Sandbox Code Playgroud)

c# mapping anonymous-types automapper

38
推荐指数
2
解决办法
2万
查看次数

标签 统计

anonymous-types ×1

automapper ×1

c# ×1

mapping ×1