lixiaojun
2022-08-17 d3024a7b50b35a8f24c1bfe0f13f4f86cc63a253
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
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 ProductInspectionContentItem
    {
        //Entity to GetModel
        private Model.ProductInspectionContentItem Entity2Model(Entity.ProductInspectionContentItem entity)
        {
            if (entity == null)
                return default;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.ProductInspectionContentItem, Model.ProductInspectionContentItem>()
            //.ForMember(d => d.DesignParas, opt => opt.MapFrom(src => Model.ProductInspectionContentItem.DesignParameters.ToModel(src.DesignParas)))
            ).CreateMapper();
            var model = mapper.Map<Entity.ProductInspectionContentItem, Model.ProductInspectionContentItem>(entity);
            return model;
        }
        //Entities to GetModels
        private List<Model.ProductInspectionContentItem> Entity2Models(List<Entity.ProductInspectionContentItem> entities)
        {
            if (entities == null || entities.Count() < 1)
                return default;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.ProductInspectionContentItem, Model.ProductInspectionContentItem>()
            // .ForMember(d => d.DesignParas, opt => opt.MapFrom(src => Model.ProductInspectionContentItem.DesignParameters.ToModel(src.DesignParas)))
            ).CreateMapper();
            var models = mapper.Map<List<Entity.ProductInspectionContentItem>, List<Model.ProductInspectionContentItem>>(entities);
            return models;
        }
 
        //Model to Entity
        private Entity.ProductInspectionContentItem Model2Entity(Model.ProductInspectionContentItem model)
        {
            if (model == null)
                return default;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.ProductInspectionContentItem, Entity.ProductInspectionContentItem>()
            // .ForMember(d => d.DesignParas, opt => opt.MapFrom(src => src.DesignParas.ToJson()))
            ).CreateMapper();
            var entity = mapper.Map<Model.ProductInspectionContentItem, Entity.ProductInspectionContentItem>(model);
            return entity;
        }
 
        //Models to Entities
        private List<Entity.ProductInspectionContentItem> Model2Entities(List<Model.ProductInspectionContentItem> models)
        {
            if (models == null || models.Count < 1)
                return default;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.ProductInspectionContentItem, Entity.ProductInspectionContentItem>()
            // .ForMember(d => d.DesignParas, opt => opt.MapFrom(src => src.DesignParas.ToJson()))
            ).CreateMapper();
            var entities = mapper.Map<List<Model.ProductInspectionContentItem>, List<Entity.ProductInspectionContentItem>>(models);
            return entities;
        }
 
        //Model to Entity
        private void Model2Entity(Model.ProductInspectionContentItem model, Entity.ProductInspectionContentItem entity)
        {
            if (model == null || entity == null)
                return;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.ProductInspectionContentItem, Entity.ProductInspectionContentItem>()
            // .ForMember(d => d.DesignParas, opt => opt.MapFrom(src => src.DesignParas.ToJson()))
             ).CreateMapper();
            mapper.Map(model, 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;
        }
 
 
 
    }
}