【问题标题】:Does AutoMapper's convention based mappings work with LINQ extension methods?AutoMapper 的基于约定的映射是否适用于 LINQ 扩展方法?
【发布时间】:2011-08-19 18:41:08
【问题描述】:

如果这是重复的,我深表歉意,但我没有找到任何与我正在寻找的东西相匹配的东西。

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

【问题讨论】:

标签: c# linq collections extension-methods automapper


【解决方案1】:

看起来新版本的 AutoMapper 现在支持这一点。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-10-16
    • 1970-01-01
    • 2017-09-01
    • 1970-01-01
    • 2014-04-29
    • 2021-09-29
    • 1970-01-01
    相关资源
    最近更新 更多