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