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