AutoMapper的基于约定的映射是否与LINQ扩展方法一起使用?

时间:2011-08-19 18:41:08

标签: c# linq collections extension-methods automapper

我很抱歉,如果这是重复但我没有发现任何与我正在寻找的东西相符的东西。

众所周知,在Automapper中我们可以执行基于约定的映射......

我的问题

是否可以访问集合中对象的扩展方法(LINQ.First()),以达到“n”级深度? 见下面的例子

我的实体

public class Store
{
    public IList< Departments > Departments {get;set;}
}

public class Departments
{
    public bool Open {get;set;}
}

我希望能做什么

Mapper.Map< Store, StoreEditModel >();

public class StoreEditModel
{
    public bool DepartmentsFirstOpen {get;set;}
}

适用(所以你觉得我不傻)

适用的用途是假设集合中的所有项目都应处于相同(开放)状态。

因此,当我的编辑模型重新处理时,我可以分别打开或关闭商店中的所有部门。

外部资源 我已经在AutoMapper的网站上阅读了以下内容.... http://automapper.codeplex.com/wikipage?title=Flattening

1 个答案:

答案 0 :(得分:0)

与新版本相似,AutoMapper现在支持此功能。

来源:http://automapper.org/blog/2011/09/22/automapper-20-released/