mirror of
https://github.com/AIDotNet/AntSK.git
synced 2026-02-17 14:06:11 +08:00
36 lines
1007 B
C#
36 lines
1007 B
C#
using AutoMapper;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Xzy.KnowledgeBase.Domain.Map
|
|
{
|
|
public static class MapperRegister
|
|
{
|
|
public static void AddMapper(this IServiceCollection services)
|
|
{
|
|
var config = new MapperConfiguration(cfg =>
|
|
{
|
|
cfg.CreateMissingTypeMaps = true;
|
|
cfg.ValidateInlineMaps = false;
|
|
cfg.ShouldMapMethod = m => false;
|
|
cfg.AddProfile<AutoMapProfile>();
|
|
});
|
|
|
|
IMapper mapper = config.CreateMapper();
|
|
|
|
//启动实体映射
|
|
Mapper.Initialize(cfg =>
|
|
{
|
|
cfg.CreateMissingTypeMaps = true;
|
|
cfg.ValidateInlineMaps = false;
|
|
cfg.ShouldMapMethod = m => false;
|
|
cfg.AddProfile<AutoMapProfile>();
|
|
});
|
|
}
|
|
}
|
|
}
|