今日长缨在手,何时缚住苍龙。这篇文章主要讲述AutoMapper5.0创建对象方法更新相关的知识,希望能为你提供帮助。
/// < summary> ///单个对象映射 /// < /summary> public static TDestination MapTo< TSource, TDestination> (TSource source) { if (source == null) return default(TDestination); Mapper.Initialize(x=> x.CreateMap(typeof(TSource), typeof(TDestination))); return Mapper.Map< TDestination> (source); }/// < summary> /// 集合列表类型映射 /// < /summary> public static List< TDestination> MapToList< TSource, TDestination> (this IEnumerable< TSource> source) { if (source == null) return default(List< TDestination> ); Mapper.Initialize(x => x.CreateMap(typeof(TSource), typeof(TDestination))); return Mapper.Map< List< TDestination> > (source); }/// < summary> /// 类型映射 /// < /summary> public static TDestination MapTo< TSource, TDestination> (this TSource source, TDestination destination) where TSource : class where TDestination : class { if (source == null) return destination; Mapper.Initialize(x => x.CreateMap(typeof(TSource), typeof(TDestination))); return Mapper.Map(source, destination); }
【AutoMapper5.0创建对象方法更新】
推荐阅读
- 集成通用Mapper
- Android开发之自己定义UI组件和属性
- Android 跨进程调用忽略权限
- 一分钟了解Android横竖屏 mdpi hdpi xhdpi xxhdpi xxxhdpi
- Android学习备忘笺01Activity
- Android应用之——自己定义控件ToggleButton
- android三种加载图片方式
- cocos2d-x 移植到android中编译的一些问题(fatal error: Box2D/Box2D.h: No such file or directory&quot;)
- call和apply的作用和区别