首页 > 代码库 > AutoMapper
AutoMapper
代码:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using AutoMapper; using WebSiteUI.Dto; using Domain; namespace WebSiteUI { public partial class AutoMapperConfiguration { /// <summary> /// 配置AutoMapper /// </summary> public static void Config() { Mapper.CreateMap<MenuDto, S_MENU>(); Mapper.CreateMap<S_MENU, MenuDto>(); Mapper.CreateMap<UserDto, S_USER>(); Mapper.CreateMap<S_USER, UserDto>(); } /// <summary> /// AutoMapper 自定义扩展配置 /// </summary> public static void ConfigExt() { //Mapper.CreateMap<MenuDto, S_MENU>().ForMember(u => u.M_CODE, e => e.MapFrom(s => s.M_CODE)); } } }
global.asax.cs
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Web; using System.Web.Mvc; using System.Web.Optimization; using System.Web.Routing; namespace WebSiteUI { public class MvcApplication : Spring.Web.Mvc.SpringMvcApplication { protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo(Server.MapPath("~/log4net.config"))); //AutoMapper AutoMapperConfiguration.Config(); AutoMapperConfiguration.ConfigExt(); } } }
AutoMapper
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。