zoukankan      html  css  js  c++  java
  • .net AutoMapper(对象与对象之间的映射器) 的简单使用

      1.注册

         /// <summary>
        /// AutoMapper 注册
        /// </summary>
        public class AutoMapperConfig
        {
            /// <summary>
            ///
            /// </summary>
            public static void Config()
            {
                Mapper.Initialize(m =>
                {
                    m.CreateMap<Model1, Model2>();
                });
            }
        }

    2.使用

    实体中使用   [MapTo("")]特性来对属性进行映射 

     Model2 newModel = Mapper.Map<Model1, Model2>(model);

    详细参考:https://www.cnblogs.com/ZaraNet/p/10000311.html

  • 相关阅读:
    好元素(good)
    三条线 (Standard IO)
    计数排序-自然顺序Comparable
    贪心算法之田忌赛马
    bzoj3400
    bzoj1704
    CF Round #456 (Div. 2)
    LA3029
    bzoj3000
    bzoj3623
  • 原文地址:https://www.cnblogs.com/zhang1f/p/11666894.html
Copyright © 2011-2022 走看看