AutoMapper README

The project's README from github.com/LuckyPennySoftware/AutoMapper. As one markdown file: README.md.

AutoMapper

CI NuGet Documentation Status

What is AutoMapper?

AutoMapper is a simple little library built to solve a deceptively complex problem - getting rid of code that mapped one object to another. This type of code is rather dreary and boring to write, so why not invent a tool to do it for us?

This is the main repository for AutoMapper, but there's more:

How do I get started?

First, configure AutoMapper to know what types you want to map, in the startup of your application:

var configuration = new MapperConfiguration(cfg => 
{
    cfg.CreateMap<Foo, FooDto>();
    cfg.CreateMap<Bar, BarDto>();
}, loggerFactory);

// or more typically, using IServiceCollection with automatic service registration
services.AddAutoMapper(cfg => 
{
    cfg.CreateMap<Foo, FooDto>();
    cfg.CreateMap<Bar, BarDto>();
});
// AutoMapper will automatically register any implementations of:
// - IValueResolver<TSource, TDestination, TDestMember>
// - IMemberValueResolver<TSource, TDestination, TSourceMember, TDestMember>
// - ITypeConverter<TSource, TDestination>
// - IValueConverter<TSourceMember, TDestinationMember>
// - ICondition<TSource, TDestination, TDestMember>
// - IPreCondition<TSource, TDestination>
// - IMappingAction<TSource, TDestination>
// from the provided assemblies

// only during development, validate your mappings; remove it before release
#if DEBUG
configuration.AssertConfigurationIsValid();
#endif
// use DI (http://docs.automapper.io/en/latest/Dependency-injection.html) or create the mapper yourself
var mapper = configuration.CreateMapper();

Then in your application code, execute the mappings:

var fooDto = mapper.Map<FooDto>(foo);
var barDto = mapper.Map<BarDto>(bar);

Check out the getting started guide. When you're done there, the wiki goes in to the nitty-gritty details. If you have questions, you can post them to Stack Overflow.

Where can I get it?

First, install NuGet. Then, install AutoMapper from the package manager console:

PM> Install-Package AutoMapper

Or from the .NET CLI as:

dotnet add package AutoMapper

Do you have an issue?

You might want to know exactly what your mapping does at runtime.

If you're still running into problems, file an issue above.

If you are a paying customer, you can contact support via your account.

How do I set the license key?

You can set the license key when registering AutoMapper:

services.AddAutoMapper(cfg => 
{
    cfg.LicenseKey = "<license key here>";
})

You can register for your license key at AutoMapper.io

AutoMapper (LuckyPennySoftware/AutoMapper)

Searching Database…

这是什么?AutoMapper 是一个基于约定的 .NET 对象到对象映射库,可以省去把一个对象的属性复制到另一个对象时所需的重复代码。
这是一个框架,还是只是一个我可以接入代码中的库?它是一个小型类库,你在 .NET 项目中引用它即可,它不是独立应用,也不是框架。你需要配置哪些类型映射到哪些类型,然后在自己的代码中调用映射器。
我该如何把它添加到我的项目中?在包管理器控制台中运行 'Install-Package AutoMapper',或通过 .NET CLI 运行 'dotnet add package AutoMapper' 安装 NuGet 包,然后在应用启动时配置类型映射,并调用 Mapper 来执行这些映射。
使用它需要购买许可证吗?AutoMapper 现在要求你在应用中注册时设置许可证密钥,可以在 AutoMapper.io 获取;付费客户还可以通过其账户获得直接的技术支持。
AutoMapper 附带哪些配套包?除了核心映射器外,还有几个可选的扩展包,包括 Collection Extensions、Expression Mapping、EF6 Extensions、IDataReader/Record Extensions 和 Enum Extensions。
我能看到映射在运行时的实际行为吗?可以。AutoMapper 允许你在运行时检查某个映射的具体行为,这有助于排查输出结果与预期不符的情况。
Size
124.5 MB
Stars
10.2K
Age
16y
Commits · 90 Days