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