【问题标题】:Emit Mapper Flattering with Custom Converters使用自定义转换器发射映射器
【发布时间】:2012-03-09 10:28:04
【问题描述】:

由于某种原因,使用此配置时自定义转换器的 Conver 函数在使用 EmitMapper 示例中的 FlatteringConfig 时不会被调用。它在使用 DefaultMapConfig 时被调用。

配置:

    var userMapper = ObjectMapperManager.DefaultInstance.GetMapper<User, UserModel>(
                   new FlatteringConfig().ConvertGeneric(typeof(IList<>), typeof(IList<>),
                new DefaultCustomConverterProvider(typeof(EntityListToModelListConverter<,>))));

关于潜在原因的任何想法?

解决方案

看看我下面的回答

【问题讨论】:

  • 请将解决方案作为答案并接受它

标签: c# mapping emitmapper


【解决方案1】:

因为 FlatteringConfig 覆盖了 GetMappingOperations 函数,所以它没有调用分配自定义转换器的 FilterOpertations 函数。所以在GetMappingOperations 中添加FilterOperations 函数调用解决了这个问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-09
    • 1970-01-01
    • 1970-01-01
    • 2011-11-11
    相关资源
    最近更新 更多