ningshuxia
2024-05-27 f51ccee7e76f598c1f718190d216f96b5ea1ca46
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
namespace IStation.Service
{
    public partial class AnalysisLog
    {
 
        //Entity to GetModel
        private static Model.AnalysisLog Entity2Model(Entity.AnalysisLog entity)
        {
            if (entity == null)
                return default;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.AnalysisLog, Model.AnalysisLog>())
            .CreateMapper();
            var model = mapper.Map<Entity.AnalysisLog, Model.AnalysisLog>(entity);
            return model;
        }
 
        //Entities to GetModels
        private static List<Model.AnalysisLog> Entity2Models(List<Entity.AnalysisLog> entities)
        {
            if (entities == null || entities.Count() < 1)
                return default;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.AnalysisLog, Model.AnalysisLog>())
            .CreateMapper();
            var models = mapper.Map<List<Entity.AnalysisLog>, List<Model.AnalysisLog>>(entities);
            return models;
        }
 
        //Model to Entity
        private static Entity.AnalysisLog Model2Entity(Model.AnalysisLog model)
        {
            if (model == null)
                return default;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.AnalysisLog, Entity.AnalysisLog>()
            ).CreateMapper();
            var entity = mapper.Map<Model.AnalysisLog, Entity.AnalysisLog>(model);
            return entity;
        }
 
        //Models to Entities
        private static List<Entity.AnalysisLog> Model2Entities(List<Model.AnalysisLog> models)
        {
            if (models == null || models.Count < 1)
                return default;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.AnalysisLog, Entity.AnalysisLog>()
            ).CreateMapper();
            var entities = mapper.Map<List<Model.AnalysisLog>, List<Entity.AnalysisLog>>(models);
            return entities;
        }
 
        //Model to Entity
        private static void Model2Entity(Model.AnalysisLog model, Entity.AnalysisLog entity)
        {
            if (model == null || entity == null)
                return;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.AnalysisLog, Entity.AnalysisLog>()
            ).CreateMapper();
            mapper.Map(model, entity);
        }
 
 
 
    }
}