zoukankan      html  css  js  c++  java
  • EF架构~对AutoMapper实体映射的扩展

    http://www.cnblogs.com/lori/p/3327898.html

    /// <summary>
        /// AutoMapper扩展方法
        /// </summary>
        public static class AutoMapperExtension
        {
            /// <summary>
            /// 集合对集合
            /// </summary>
            /// <typeparam name="TResult"></typeparam>
            /// <param name="self"></param>
            /// <returns></returns>
            public static List<TResult> MapTo<TResult>(this IEnumerable self)
            {
                if (self == null)
                    throw new ArgumentNullException();
                Mapper.CreateMap(self.GetType(), typeof(TResult));
                return (List<TResult>)Mapper.Map(self, self.GetType(), typeof(List<TResult>));
            }
            /// <summary>
            /// 对象对对象
            /// </summary>
            /// <typeparam name="TResult"></typeparam>
            /// <param name="self"></param>
            /// <returns></returns>
            public static TResult MapTo<TResult>(this object self)
            {
                if (self == null)
                    throw new ArgumentNullException();
                Mapper.CreateMap(self.GetType(), typeof(TResult));
                return (TResult)Mapper.Map(self, self.GetType(), typeof(TResult));
            }
    
        }
  • 相关阅读:
    sizeof、strlen、length、size
    extern关键字
    结构
    引用
    指针
    数组
    linux端口 ,打开服务端口
    linux用户禁用
    防止验证码的恶意发送
    springboot 项目windows下打包、注册服务。
  • 原文地址:https://www.cnblogs.com/shiningrise/p/5615767.html
Copyright © 2011-2022 走看看