ningshuxia
2022-08-19 153da1eef16b51d75442779a3964a1c5413132e4
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
using AutoMapper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace IStation.Service
{
    public partial class ProductModifyRecord
    {
        //Entity to GetModel
        private static Model.ProductModifyRecord Entity2Model(Entity.ProductModifyRecord entity)
        {
            if (entity == null)
                return default;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.ProductModifyRecord, Model.ProductModifyRecord>()).CreateMapper();
            var model = mapper.Map<Entity.ProductModifyRecord, Model.ProductModifyRecord>(entity);
            return model;
        }
        //Entities to GetModels
        private static List<Model.ProductModifyRecord> Entity2Models(List<Entity.ProductModifyRecord> entities)
        {
            if (entities == null || entities.Count() < 1)
                return default;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.ProductModifyRecord, Model.ProductModifyRecord>()).CreateMapper();
            var models = mapper.Map<List<Entity.ProductModifyRecord>, List<Model.ProductModifyRecord>>(entities);
            return models;
        }
 
        //Model to Entity
        private static Entity.ProductModifyRecord Model2Entity(Model.ProductModifyRecord model)
        {
            if (model == null)
                return default;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.ProductModifyRecord, Entity.ProductModifyRecord>()).CreateMapper();
            var entity = mapper.Map<Model.ProductModifyRecord, Entity.ProductModifyRecord>(model);
            return entity;
        }
 
        //Models to Entities
        private static List<Entity.ProductModifyRecord> Model2Entities(List<Model.ProductModifyRecord> models)
        {
            if (models == null || models.Count < 1)
                return default;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.ProductModifyRecord, Entity.ProductModifyRecord>()).CreateMapper();
            var entities = mapper.Map<List<Model.ProductModifyRecord>, List<Entity.ProductModifyRecord>>(models);
            return entities;
        }
 
        //Model to Entity
        private static void Model2Entity(Model.ProductModifyRecord model, Entity.ProductModifyRecord entity)
        {
            if (model == null || entity == null)
                return;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.ProductModifyRecord, Entity.ProductModifyRecord>()).CreateMapper();
            mapper.Map(model, entity);
        }
    }
}