• Stars
    star
    217
  • Rank 181,637 (Top 4 %)
  • Language
    C#
  • License
    MIT License
  • Created over 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

πŸ¦‡ Convention-based, fast object mapper.

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

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.

More Repositories

1

compose-date-picker

Android DatePicker with month and year build with Compose UI
Kotlin
66
star
2

cs-to-ts

🏭 From C# to TypeScript.
C#
55
star
3

compose-progress

Kotlin
20
star
4

springkafkadoc

Auto Generated Kafka Documentation for Spring Boot
Kotlin
15
star
5

spring-redis-reactive-cache

Adds annotation support to Spring for reactive cache operations
Kotlin
10
star
6

spring-ktx

Kotlin
5
star
7

springkafkadoc-example

This repository serves as a guide for combining the documentation for spring kafka and event catalog for documenting asynchronous calls.
Kotlin
5
star
8

InteractiveAssistant

A chatbot implementation with Microsoft Cognitive Services
5
star
9

DogusTeknoloji.github.io

Doğuş Teknoloji Document Hub
5
star
10

Soltree

.Net 6 + GraphQL + Vue.js 3 Γ–rnek Uygulama
C#
4
star
11

advanced-csharp

C#
3
star
12

turkuaz-ts-core

This project include core functionalities for Turkuaz Vue Projects.
TypeScript
3
star
13

DSM.Core

DSM Core Module
C#
2
star
14

circular-ref-fix

🎑 Fixes circular dependencies using $id identifiers and $ref pointers. Produces Json.NET friendly result.
JavaScript
2
star
15

DSM-UI-Solution

Site Management and Monitoring Services / Open APMM
Vue
2
star
16

JumbleComponentRegistry

Composite UI Component Registry
TypeScript
2
star
17

java_examples_number_games

This is an example project for newbie java developers.
Java
1
star
18

typescript-tutorial

Internal training material
TypeScript
1
star
19

RabbitMQClusterSample

C#
1
star
20

dsm-ui-api

DSM UI Api
C#
1
star
21

java_examples_prime_number_finder

This is an example project for newbie java developers.
Java
1
star
22

dt-cs-event-poco-proxy-generator

Dynamic POCO Type Generator for Event Interfaces by C#
C#
1
star