相关疑难解决方法(0)

使用AutoMapper取消DTO

我一直在尝试使用AutoMapper来节省从我的DTO到我的域对象的时间,但是我在配置地图时遇到了麻烦,以至于它工作正常,我开始怀疑AutoMapper是否可能是错误的工具工作.

考虑这个域对象的例子(一个实体和一个值):

public class Person
{
    public string Name { get; set; }
    public StreetAddress Address { get; set; }
}

public class StreetAddress
{
    public string Address { get; set; }
    public string City { get; set; }
    public string State { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

我的DTO(来自Linq-to-SQL对象)的出现大致如下:

public class PersonDTO
{
    public string Name { get; set; }
    public string Address { get; set; }
    public string City { get; set; }
    public string State { get; set; } …
Run Code Online (Sandbox Code Playgroud)

mapping automapper

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

标签 统计

automapper ×1

mapping ×1