コード例 #1
0
        public void TestComprehensiveToComprehensiveModel()
        {
            Comprehensive c = this._serviceCpl.Get(1);

            Mapper.CreateMap <Comprehensive, ComprehensiveSimplify>();
            ComprehensiveSimplify model = Mapper.Map <ComprehensiveSimplify>(c);
            //   model = Mapper.Map(c.PhyGeoDisaster, model);
        }
コード例 #2
0
        ///// <summary>
        ///// 通过主键编号精准查询唯一的灾害点地质调查完整实体
        ///// 请根据业务调用具体实体
        ///// </summary>
        ///// <param name="id">灾害点唯一编号</param>
        ///// <returns>灾害点完整信息</returns>
        //public Comprehensive Get(int id)
        //{
        //    if (id <= 0)
        //        throw new Exception("不存在这样的灾害点信息主键编号");
        //   Comprehensive g = _cpsService.Get(id);
        //   return g;
        //}

        /// <summary>
        /// 通过主键编号获取灾害点简要实体
        /// </summary>
        /// <param name="id">灾害点唯一编号</param>
        /// <returns></returns>
        public ComprehensiveSimplify GetById(int id)
        {
            if (id <= 0)
            {
                throw new Exception("不存在这样的灾害点信息主键编号");
            }
            Comprehensive         g = _cpsService.Get(id);
            ComprehensiveSimplify c = Mapper.Map <ComprehensiveSimplify>(g);

            return(c);
        }
コード例 #3
0
        public void TestComplexAutoMapper()
        {
            DebrisFlow d = this._service.Get(1);


            var comprehensiveModel = new ComprehensiveSimplify();

            Mapper.CreateMap <Comprehensive, ComprehensiveSimplify>();
            //Mapper.CreateMap<DebrisFlow, DebrisFlowModel>()
            //    .ForMember("ComprehensiveModel", o => o.MapFrom(e => e.Comprehensive));
            DebrisFlowModel m = Mapper.Map <DebrisFlow, DebrisFlowModel>
                                    (d);
        }
コード例 #4
0
        public void TestSample()
        {
            Comprehensive cmp = new Comprehensive()
            {
                称 = "1111",
                //PhyGeoDisaster = new PhyGeoDisaster()
                //{
                //    Location="dddddd"
                //}
            };

            Mapper.CreateMap <Comprehensive, ComprehensiveSimplify>();
            ComprehensiveSimplify model = Mapper.Map <ComprehensiveSimplify>(cmp);

            Assert.AreEqual("1111", model.称);
            Assert.AreEqual("dddddd", model.地理位置);
        }