繁体   English   中英

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

[英]Does AutoMapper's convention based mappings work with LINQ extension methods?

如果这是重复的邮件,我深表歉意,但没有找到与我要查找的内容相匹配的任何内容。

众所周知,在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

在新版本中,AutoMapper现在支持此功能。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM