Last active
September 5, 2023 08:13
-
-
Save ismkdc/3991e816975f2149b0f4d10eb7ad8227 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Linq; | |
using FastExpressionCompiler; | |
using Mapster; | |
namespace foobar; | |
public static class MappingConfiguration | |
{ | |
public static TypeAdapterConfig Generate() | |
{ | |
var config = new TypeAdapterConfig(); | |
config.NewConfig<foo, bar>() | |
.Map(dest => dest.Color, | |
src => src.Category.Color) | |
.Map(dest => dest.CategorySlug, | |
src => src.Category.Slug) | |
.Ignore(dest => dest.Reactions); | |
config.NewConfig<lol, asd>(); | |
config.Compiler = exp => exp.CompileFast(); | |
config.Compile(); | |
return config; | |
} | |
} | |
### ON STARTUP ### | |
//register mapster | |
var config = MappingConfiguration.Generate(); | |
services.AddSingleton(config); | |
services.AddSingleton<IMapper, ServiceMapper>(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment