namespace HStation.Service
|
{
|
public partial class AssetsPumpMain
|
{
|
//Entity to GetModel
|
internal static Model.AssetsPumpMain Entity2Model(Entity.AssetsPumpMain entity)
|
{
|
if (entity == null)
|
return default;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.AssetsPumpMain, Model.AssetsPumpMain>()
|
.ForMember(d => d.Paras, opt => opt.MapFrom(src => ParasHelper.ToDictionary(src.Paras)))
|
.ForMember(d => d.Flags, opt => opt.MapFrom(src => FlagsHelper.ToList(src.Flags)))
|
.ForMember(d => d.KeyWord, opt => opt.MapFrom(src => KeyWordHelper.ToList(src.KeyWord)))
|
).CreateMapper();
|
var model = mapper.Map<Entity.AssetsPumpMain, Model.AssetsPumpMain>(entity);
|
return model;
|
}
|
|
//Entities to GetModels
|
internal static List<Model.AssetsPumpMain> Entity2Models(List<Entity.AssetsPumpMain> entities)
|
{
|
if (entities == null || entities.Count < 1)
|
return default;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.AssetsPumpMain, Model.AssetsPumpMain>()
|
.ForMember(d => d.Paras, opt => opt.MapFrom(src => ParasHelper.ToDictionary(src.Paras)))
|
.ForMember(d => d.Flags, opt => opt.MapFrom(src => FlagsHelper.ToList(src.Flags)))
|
.ForMember(d => d.KeyWord, opt => opt.MapFrom(src => KeyWordHelper.ToList(src.KeyWord)))
|
).CreateMapper();
|
var models = mapper.Map<List<Entity.AssetsPumpMain>, List<Model.AssetsPumpMain>>(entities);
|
return models;
|
}
|
|
//Model to Entity
|
internal static Entity.AssetsPumpMain Model2Entity(Model.AssetsPumpMain model)
|
{
|
if (model == null)
|
return default;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.AssetsPumpMain, Entity.AssetsPumpMain>()
|
.ForMember(d => d.Paras, opt => opt.MapFrom(src => ParasHelper.ToString(src.Paras)))
|
.ForMember(d => d.Flags, opt => opt.MapFrom(src => FlagsHelper.ToString(src.Flags)))
|
.ForMember(d => d.KeyWord, opt => opt.MapFrom(src => KeyWordHelper.ToString(src.KeyWord)))
|
).CreateMapper();
|
var entity = mapper.Map<Model.AssetsPumpMain, Entity.AssetsPumpMain>(model);
|
return entity;
|
}
|
|
//Models to Entities
|
internal static List<Entity.AssetsPumpMain> Model2Entities(List<Model.AssetsPumpMain> models)
|
{
|
if (models == null || models.Count < 1)
|
return default;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.AssetsPumpMain, Entity.AssetsPumpMain>()
|
.ForMember(d => d.Paras, opt => opt.MapFrom(src => ParasHelper.ToString(src.Paras)))
|
.ForMember(d => d.Flags, opt => opt.MapFrom(src => FlagsHelper.ToString(src.Flags)))
|
.ForMember(d => d.KeyWord, opt => opt.MapFrom(src => KeyWordHelper.ToString(src.KeyWord)))
|
).CreateMapper();
|
var entities = mapper.Map<List<Model.AssetsPumpMain>, List<Entity.AssetsPumpMain>>(models);
|
return entities;
|
}
|
|
//Model to Entity
|
internal static void Model2Entity(Model.AssetsPumpMain model, Entity.AssetsPumpMain entity)
|
{
|
if (model == null || entity == null)
|
return;
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.AssetsPumpMain, Entity.AssetsPumpMain>()
|
.ForMember(d => d.KeyWord, opt => opt.MapFrom(src => KeyWordHelper.ToString(src.KeyWord)))
|
).CreateMapper();
|
mapper.Map(model, entity);
|
}
|
}
|
}
|