using AutoMapper; using System.Collections.Generic; using System.Linq; namespace IStation.BLL { public partial class SignalType { //Entity to GetModel private static Model.SignalType Entity2Model(Entity.SignalType entity) { if (entity == null) return default; var mapper = new MapperConfiguration(cfg => cfg.CreateMap() .ForMember(d => d.FormatParas, opt => opt.MapFrom(src => src.FormatParas))).CreateMapper(); var model = mapper.Map(entity); return model; } //Entities to GetModels private static List Entity2Models(List entities) { if (entities == null || entities.Count() < 1) return default; var mapper = new MapperConfiguration(cfg => cfg.CreateMap() .ForMember(d => d.FormatParas, opt => opt.MapFrom(src => src.FormatParas))).CreateMapper(); var models = mapper.Map, List>(entities); return models; } //Model to Entity private static Entity.SignalType Model2Entity(Model.SignalType model) { if (model == null) return default; var mapper = new MapperConfiguration(cfg => cfg.CreateMap() .ForMember(d => d.FormatParas, opt => opt.MapFrom(src => src.FormatParas))).CreateMapper(); var entity = mapper.Map(model); return entity; } //Models to Entities private static List Model2Entities(List models) { if (models == null || models.Count < 1) return default; var mapper = new MapperConfiguration(cfg => cfg.CreateMap() .ForMember(d => d.FormatParas, opt => opt.MapFrom(src => src.FormatParas))).CreateMapper(); var entities = mapper.Map, List>(models); return entities; } //Model to Entity private static void Model2Entity(Model.SignalType model, Entity.SignalType entity) { if (model == null || entity == null) return; var mapper = new MapperConfiguration(cfg => cfg.CreateMap() .ForMember(d => d.FormatParas, opt => opt.MapFrom(src => src.FormatParas))).CreateMapper(); mapper.Map(model, entity); } } }