lixiaojun
2023-03-21 c6c912c9a0b1235805dea4fbb471e26a7f13a47d
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
using AutoMapper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace IStation.Service
{
    public partial class SpecialPropertyValue
    {
 
        //Entity to GetModel
        private Model.SpecialPropertyValue Entity2Model(Entity.SpecialPropertyValue entity)
        {
            if (entity == null)
                return default;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.SpecialPropertyValue, Model.SpecialPropertyValue>()).CreateMapper();
            var model = mapper.Map<Entity.SpecialPropertyValue, Model.SpecialPropertyValue>(entity);
            return model;
        }
        //Entities to GetModels
        private List<Model.SpecialPropertyValue> Entity2Models(List<Entity.SpecialPropertyValue> entities)
        {
            if (entities == null || entities.Count() < 1)
                return default;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.SpecialPropertyValue, Model.SpecialPropertyValue>()).CreateMapper();
            var models = mapper.Map<List<Entity.SpecialPropertyValue>, List<Model.SpecialPropertyValue>>(entities);
            return models;
        }
 
        //Model to Entity
        private Entity.SpecialPropertyValue Model2Entity(Model.SpecialPropertyValue model)
        {
            if (model == null)
                return default;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.SpecialPropertyValue, Entity.SpecialPropertyValue>()).CreateMapper();
            var entity = mapper.Map<Model.SpecialPropertyValue, Entity.SpecialPropertyValue>(model);
            return entity;
        }
 
        //Models to Entities
        private List<Entity.SpecialPropertyValue> Model2Entities(List<Model.SpecialPropertyValue> models)
        {
            if (models == null || models.Count < 1)
                return default;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.SpecialPropertyValue, Entity.SpecialPropertyValue>()).CreateMapper();
            var entities = mapper.Map<List<Model.SpecialPropertyValue>, List<Entity.SpecialPropertyValue>>(models);
            return entities;
        }
 
        //Model to Entity
        private void Model2Entity(Model.SpecialPropertyValue model, Entity.SpecialPropertyValue entity)
        {
            if (model == null || entity == null)
                return;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.SpecialPropertyValue, Entity.SpecialPropertyValue>()).CreateMapper();
            mapper.Map(model, entity);
        }
    }
}