BatMap

当前版本: 1.1.12


BatMap是什么?

蝙蝠地图-我们应得的,而不是我们需要的。 OPENING(还有另一个)映射器,主要用于EF实体和DTO之间的co转换。
BatMap - The Mapper we deserve, not the one we need. Opininated (yet another) mapper, mainly to convert between EF Entities and DTOs.

许可协议

MIT

关键词

Mapper , Projector , Mapping , Entity , DTO

安装方式

Install-Package BatMap -Version 1.1.12

相关网址


BatMap使用说明

BatMap - The Mapper we deserve, not the one we need.

🦇 BatMap Opininated (yet another) mapper, mainly to convert between EF Entities and DTOs.

Supports .Net Standard 1.0.

Build status Coverage Status NuGet Badge Join the chat at https://gitter.im/NaNaNaNaBatMap/Lobby GitHub issues GitHub license

GitHub stars GitHub forks

Let's first obey the number one rule for mappers, a benchmark (using BenchmarkDotNet):

Method Mean
HandWritten 1.143 ms
BatMap 💥 2.000 ms
SafeMapper 2.933 ms
Mapster 2.942 ms
AutoMapper 3.497 ms
TinyMapper 4.172 ms
ExpressMapper 6.955 ms
FastMapper 9.203 ms

Results may (probably) vary. Latest run can bee seen on Appveyor Build.

  • Fast (enough)
  • NOT over-engineered, code is really simple
  • Instantiatable mapper
  • Convention based, zero configuration static shortcut exists too (obviously named Mapper)
  • Does not crash when faced with circular-dependencies during registration
  • In fact, can resolve recurring instances to same target instance (yaay no StackOverflowException!)
  • Can project IQueryable<TSource> to IQueryable<TTarget> with respect to includes (via auto-detection or with custom parameters)
  • and much more...

API (API接口)

Registration with static API:

Mapper.RegisterMap<Customer, CustomerDTO>();

or use an instance:

var mapper = new MapConfiguration(dynamicMapping: DynamicMapping.MapAndCache, preserveReferences: true);
mapper.RegisterMap<Customer, CustomerDTO>();

Note: You don't have to register type mappings when using a MapConfiguration with Dynamic Mapping enabled (like the static API uses).

You can customize expressions for members:

mapper.RegisterMap<Order, OrderDTO>(b => b.MapMember(o => o.Price, (o, mc) => o.Count * o.UnitPrice));

Map an object:

Mapper.Map<CustomerDTO>(customer);

Map an enumerable:

customers.MapTo<Customer, CustomerDTO>(preserveReferences: true);  // extension methods FTW!

Project a query:

customerQuery.ProjectTo<CustomerDTO>(checkIncludes: true);

or with expanding specific navigations:

customerQuery.ProjectTo<Customer, CustomerDTO>(c => c.Addresses, c => c.Orders);

Note: If you want to change mapping behavior, create a class that inherits from ExpressionProvider, override CreateMemberBinding and inject an instance of your class to MapConfiguration.

Where can I get it?

You can install BatMap from the package manager console:

PM> Install-Package BatMap

Documentation (文档)

You might want to visit wiki for more.


Developed with ❤️ at Doğuş Teknoloji.

项目热度

项目信息

分享到

基本信息
开发语言
C#
相关项目
2
相关仓库
1
Watchers
28
Stars
181
Forks
21
版本数量
28
最新发布
2019-12-02
首次发布
1900-01-01
仓库大小
184 KB

版本历史
1.1.12
2019-12-02
1.1.3
2018-02-27
1.1.2
2017-10-19
1.1.1
2017-09-21
1.1.0
2017-09-13
1.0.2
2017-08-02
1.0.0
2017-06-19
0.2.39
2017-06-19
0.2.24
2017-06-08
0.2.19
2017-06-02

贡献者
Umut Ozel The Gitter Badger