lixiaojun
2024-07-26 7026a215a38e7d77da2104e2d11d17fc2065d80d
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
namespace HStation.Service
{
    public partial class XhsPhartGraph
    {
        /// <summary>
        /// Entity to Model
        /// </summary>
        public static Model.XhsPhartGraph Entity2Model(Entity.XhsPhartGraph entity)
        {
            if (entity == null)
                return default;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.XhsPhartGraph, Model.XhsPhartGraph>()
            .ForMember(d => d.Paras, opt => opt.MapFrom(src => ParasHelper.ToDictionary(src.Paras)))
            .ForMember(d => d.Flags, opt => opt.MapFrom(src => FlagsHelper.ToList(src.Flags))))
            .CreateMapper();
            var model = mapper.Map<Entity.XhsPhartGraph, Model.XhsPhartGraph>(entity);
            return model;
        }
 
        /// <summary>
        /// Entities to Models
        /// </summary>
        public static List<Model.XhsPhartGraph> Entity2Models(List<Entity.XhsPhartGraph> entities)
        {
            if (entities == null || entities.Count() < 1)
                return default;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.XhsPhartGraph, Model.XhsPhartGraph>()
            .ForMember(d => d.Paras, opt => opt.MapFrom(src => ParasHelper.ToDictionary(src.Paras)))
            .ForMember(d => d.Flags, opt => opt.MapFrom(src => FlagsHelper.ToList(src.Flags))))
            .CreateMapper();
            var models = mapper.Map<List<Entity.XhsPhartGraph>, List<Model.XhsPhartGraph>>(entities);
            return models;
        }
 
        /// <summary>
        /// Model to Entity
        /// </summary>
        public static Entity.XhsPhartGraph Model2Entity(Model.XhsPhartGraph model)
        {
            if (model == null)
                return default;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.XhsPhartGraph, Entity.XhsPhartGraph>()
            .ForMember(d => d.Paras, opt => opt.MapFrom(src => ParasHelper.ToString(src.Paras)))
            .ForMember(d => d.Flags, opt => opt.MapFrom(src => FlagsHelper.ToString(src.Flags))))
            .CreateMapper();
            var entity = mapper.Map<Model.XhsPhartGraph, Entity.XhsPhartGraph>(model);
            return entity;
        }
 
        /// <summary>
        /// Models to Entities
        /// </summary>
        public static List<Entity.XhsPhartGraph> Model2Entities(List<Model.XhsPhartGraph> models)
        {
            if (models == null || models.Count < 1)
                return default;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.XhsPhartGraph, Entity.XhsPhartGraph>()
            .ForMember(d => d.Paras, opt => opt.MapFrom(src => ParasHelper.ToString(src.Paras)))
            .ForMember(d => d.Flags, opt => opt.MapFrom(src => FlagsHelper.ToString(src.Flags))))
            .CreateMapper();
            var entities = mapper.Map<List<Model.XhsPhartGraph>, List<Entity.XhsPhartGraph>>(models);
            return entities;
        }
 
        /// <summary>
        /// Model to Entity
        /// </summary>
        public static void Model2Entity(Model.XhsPhartGraph model, Entity.XhsPhartGraph entity)
        {
            if (model == null || entity == null)
                return;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.XhsPhartGraph, Entity.XhsPhartGraph>()
            .ForMember(d => d.Paras, opt => opt.MapFrom(src => ParasHelper.ToString(src.Paras)))
            .ForMember(d => d.Flags, opt => opt.MapFrom(src => FlagsHelper.ToString(src.Flags))))
            .CreateMapper();
            mapper.Map(model, entity);
        }
 
    }
}