开发者

Automapper, mapping IEnumearble<Foo> to IEnumearble<FooDto>

开发者 https://www.devze.com 2023-01-09 16:28 出处:网络
I ve been trying to do something like this: ... Mapper.CreateMap<IEnumerable<Foo>, IEnumerable<FooDto>>();

I ve been trying to do something like this:

    ...
Mapper.CreateMap<IEnumerable<Foo>, IEnumerable<FooDto>>();
var fooDtos = Mapper.Map<IEnumerable<Foo>, IEnumerable<FooDto>>(foos);

Keep in 开发者_JAVA百科mind that Foo is an entity but the properties are exactly the same that FooDto. The Result of fooDtos is an empty enumerable Tips?


ok Its simple I should have mapped like this :

Mapper.CreateMap<Foo, FooDto>();

and that works Doh!

0

精彩评论

暂无评论...
验证码 换一张
取 消