tangxu
2024-01-09 ddc2780231ea76be74fadb7486401a3d0d17b101
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 Yw.Service
{
    public partial class HealthIndex
    {
        //Entity to Model
        private static Model.HealthIndex Entity2Model(Entity.HealthIndex entity)
        {
            if (entity == null)
                return default;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.HealthIndex, Model.HealthIndex>()).CreateMapper();
            var model = mapper.Map<Entity.HealthIndex, Model.HealthIndex>(entity);
            return model;
        }
 
        //Entities to Models
        private static List<Model.HealthIndex> Entity2Models(List<Entity.HealthIndex> entities)
        {
            if (entities == null || entities.Count() < 1)
                return default;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.HealthIndex, Model.HealthIndex>()).CreateMapper();
            var models = mapper.Map<List<Entity.HealthIndex>, List<Model.HealthIndex>>(entities);
            return models;
        }
 
        //Model to Entity
        private static Entity.HealthIndex Model2Entity(Model.HealthIndex model)
        {
            if (model == null)
                return default;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.HealthIndex, Entity.HealthIndex>()).CreateMapper();
            var entity = mapper.Map<Model.HealthIndex, Entity.HealthIndex>(model);
            return entity;
        }
 
        //Models to Entities
        private static List<Entity.HealthIndex> Model2Entities(List<Model.HealthIndex> models)
        {
            if (models == null || models.Count < 1)
                return default;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.HealthIndex, Entity.HealthIndex>()).CreateMapper();
            var entities = mapper.Map<List<Model.HealthIndex>, List<Entity.HealthIndex>>(models);
            return entities;
        }
 
        //Model to Entity
        private static void Model2Entity(Model.HealthIndex model, Entity.HealthIndex entity)
        {
            if (model == null || entity == null)
                return;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.HealthIndex, Entity.HealthIndex>()).CreateMapper();
            mapper.Map(model, entity);
        }
 
    }
}