using AutoMapper; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace FLY.Weight2.Server.Model { /// /// LC 与 DB 类的映射关系, 会在程序入口处, 手动使用 /// var assemblies = System.AppDomain.CurrentDomain.GetAssemblies(); /// var cfg = new MapperConfigurationExpression(); /// cfg.AddMaps(assemblies); /// Mapper.Initialize(cfg); /// /// 枚举全部程序集 中的AutoMapper.Profile 全部加载!!! /// public class Lc_AutoMapperProfile { public static Mapper Mapper { get; } = new AutoMapper.Mapper(new MapperConfiguration(c => { c. CreateMap() .ForMember(s => s.Items, opt => { opt.MapFrom(s => Newtonsoft.Json.JsonConvert.SerializeObject(s.Items)); }) .ReverseMap() .ForMember(s => s.Items, opt => { opt.MapFrom(s => Newtonsoft.Json.JsonConvert.DeserializeObject>(s.Items)); }); })); } }