Shuxia Ning
2024-10-08 cf4967a0aebab18c5a37137f3e4c61b2d73a54bb
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 AnalysisFactor
    {
 
        //Entity to GetModel
        private static Model.AnalysisFactor Entity2Model(Entity.AnalysisFactor entity)
        {
            if (entity == null)
                return default;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.AnalysisFactor, Model.AnalysisFactor>() 
            ).CreateMapper();
            var model = mapper.Map<Entity.AnalysisFactor, Model.AnalysisFactor>(entity);
            return model;
        }
 
        //Entities to GetModels
        private static List<Model.AnalysisFactor> Entity2Models(List<Entity.AnalysisFactor> entities)
        {
            if (entities == null || entities.Count() < 1)
                return default;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.AnalysisFactor, Model.AnalysisFactor>() 
            ).CreateMapper();
            var models = mapper.Map<List<Entity.AnalysisFactor>, List<Model.AnalysisFactor>>(entities);
            return models;
        }
 
        //Model to Entity
        private static Entity.AnalysisFactor Model2Entity(Model.AnalysisFactor model)
        {
            if (model == null)
                return default;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.AnalysisFactor, Entity.AnalysisFactor>() 
            ).CreateMapper();
            var entity = mapper.Map<Model.AnalysisFactor, Entity.AnalysisFactor>(model);
            return entity;
        }
 
        //Models to Entities
        private static List<Entity.AnalysisFactor> Model2Entities(List<Model.AnalysisFactor> models)
        {
            if (models == null || models.Count < 1)
                return default;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.AnalysisFactor, Entity.AnalysisFactor>() 
            ).CreateMapper();
            var entities = mapper.Map<List<Model.AnalysisFactor>, List<Entity.AnalysisFactor>>(models);
            return entities;
        }
 
        //Model to Entity
        private static void Model2Entity(Model.AnalysisFactor model, Entity.AnalysisFactor entity)
        {
            if (model == null || entity == null)
                return;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.AnalysisFactor, Entity.AnalysisFactor>() 
            ).CreateMapper();
            mapper.Map(model, entity);
        }
 
 
 
    }
}