【发布时间】:2017-12-27 16:13:58
【问题描述】:
public class ObjectA
{
string abc {get; set;}
}
public class ObjectB
{
string abc {get; set;}
string bla {get; set;}
}
public class A
{
public string x { get; set; }
public ICollection<ObjectA> CollectionA {get; set;}
}
public class B
{
public string x { get; set; }
public ICollection<Object B> CollectionB { get; set; }
}
cfg.CreateMap<A, B>()
.ForMember(dest => dest.CollectionB, opt => opt.MapFrom(src => src.CollectionA));
您好,我想保留 Collection 但忽略里面的 bla 字符串,我该如何实现?
我想我必须这样做: .ForSourceMember(x => x.CollectionB, opt => opt.Ignore());
在 automapper 文档中进行了搜索,但找不到使用集合执行此操作的方法。 有人可以帮助我吗? 谢谢!
【问题讨论】:
标签: c# collections automapper