Shuxia Ning
2024-08-20 d36d96955f33f03130d2de2f3ea8838f91600f05
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
namespace HStation.Service
{
    public partial class XhsValveMainPhartMapping
    {
        //Entity to Model
        private static Model.XhsValveMainPhartMapping Entity2Model(Entity.XhsValveMainPhartMapping entity)
        {
            if (entity == null)
                return default;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.XhsValveMainPhartMapping, Model.XhsValveMainPhartMapping>()).CreateMapper();
            var model = mapper.Map<Entity.XhsValveMainPhartMapping, Model.XhsValveMainPhartMapping>(entity);
            return model;
        }
 
        //Entities to Models
        private static List<Model.XhsValveMainPhartMapping> Entity2Models(List<Entity.XhsValveMainPhartMapping> entities)
        {
            if (entities == null || entities.Count() < 1)
                return default;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.XhsValveMainPhartMapping, Model.XhsValveMainPhartMapping>()).CreateMapper();
            var models = mapper.Map<List<Entity.XhsValveMainPhartMapping>, List<Model.XhsValveMainPhartMapping>>(entities);
            return models;
        }
 
        //Model to Entity
        internal static Entity.XhsValveMainPhartMapping Model2Entity(Model.XhsValveMainPhartMapping model)
        {
            if (model == null)
                return default;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.XhsValveMainPhartMapping, Entity.XhsValveMainPhartMapping>()).CreateMapper();
            var entity = mapper.Map<Model.XhsValveMainPhartMapping, Entity.XhsValveMainPhartMapping>(model);
            return entity;
        }
 
        //Models to Entities
        private static List<Entity.XhsValveMainPhartMapping> Model2Entities(List<Model.XhsValveMainPhartMapping> models)
        {
            if (models == null || models.Count < 1)
                return default;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.XhsValveMainPhartMapping, Entity.XhsValveMainPhartMapping>()).CreateMapper();
            var entities = mapper.Map<List<Model.XhsValveMainPhartMapping>, List<Entity.XhsValveMainPhartMapping>>(models);
            return entities;
        }
 
        //Model to Entity
        private static void Model2Entity(Model.XhsValveMainPhartMapping model, Entity.XhsValveMainPhartMapping entity)
        {
            if (model == null || entity == null)
                return;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.XhsValveMainPhartMapping, Entity.XhsValveMainPhartMapping>()).CreateMapper();
            mapper.Map(model, entity);
        }
 
    }
}