Slapper.AutoMapper 2.0.5

Install-Package Slapper.AutoMapper -Version 2.0.5
dotnet add package Slapper.AutoMapper --version 2.0.5
<PackageReference Include="Slapper.AutoMapper" Version="2.0.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Slapper.AutoMapper --version 2.0.5
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Slapper.AutoMapper, 2.0.5"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Slapper.AutoMapper as a Cake Addin
#addin nuget:?package=Slapper.AutoMapper&version=2.0.5

// Install Slapper.AutoMapper as a Cake Tool
#tool nuget:?package=Slapper.AutoMapper&version=2.0.5
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Slapper.AutoMapper

Slap your data into submission.

Slapper.AutoMapper maps dynamic data to static types.

What is it?

Slapper.AutoMapper ( Pronounced Slapper-Dot-Automapper ) is a mapping library that can convert dynamic data into static types and populate complex nested child objects.

It primarily converts C# dynamics and IDictionary<string, object> to strongly typed objects and supports populating an entire object graph by using underscore notation to underscore into nested objects.

Why use an IDictionary? Because a C# dynamic ( well really an ExpandoObject ) can easily be cast to one allowing this library to be used in a variety of ways not only with dictionaries of property names and values but with dynamics as well.

Okay, so what... doesn't other ORMs do this?

Answer: Yes and no but the philosophy of this project is much different. This small library is meant to be used as a building block in a larger solution and puts a great emphasis on its ability to map to complex nested properties such as mapping a Customer and it's list of Orders and it's list of OrderDetails.

Is this an ORM?

No, this is not an ORM in itself but can easily be extended to create one. This library can be thought of as a building block of an ORM or used as an extension to an existing ORM or Micro-ORM.

ORMs typically query the database and then map the data into objects. Slapper just handles the mapping part and essentially only has one input: a dictionary of property names and values.

What problems does this solve?

Simply put, it allows you to convert dynamic data into strongly typed objects with ease and populating complex nested child objects in your object hierarchy comes free out of the box --something severely lacking in almost every Micro-ORM solution!

Auto mapping?

Yep, Slapper.AutoMapper stays true to its name and allows auto-mapping between dynamic data and static types by using conventions to find a given classes identifier ( the property that gives the class uniqueness ). This allows Slapper to figure out how to effectively group objects together so that you do not get duplicate results. You can even supply your own conventions or manually specify the identifiers by either calling a simple API method or decorating your types with an attribute.

And yes, multiple identifiers aka Composite Primary Keys are supported out of the box!

Some more ramblings...

Micro-ORMs have been springing up left and right but many of them are quite basic in their functionality. Many have also been opting for either very basic mapping to strongly typed objects or skipping it completely and opting for a completely dynamic solution.

Dynamics are super cool and have their place but strongly typed objects have their place too and that is what this library focuses on... converting dynamic data into strongly typed objects with strong support for populating nested child properties.

Target Audience

The target audience is C# developers looking to enhance an ORM or write their own. Slapper.AutoMapper can take care of a lot of the hard work of mapping back to strongly typed objects.

Because Slapper.AutoMappers primary input is simply a dictionary of property names and values, as long as you can get your data into that form, you're good to go. One thing to note is that the values must be the same data types as the strongly typed object's properties/fields you are wishing to populate. Slapper.AutoMapper does not handle data type conversions, that is up to you the consumer to feed the proper data into the library.

And that's it, feel free to explore the examples below and the unit tests and hack away. This library is licensed with the MIT license so feel free to re-use the code in your own projects any way you please. I only ask that you keep the license comment at the top of the file or any file that uses significant portions of this projects code for proper attribution.

Slapper.AutoMapper is also available on NuGet as a compiled dll if you prefer that. Check it out at: http://www.nuget.org/packages/Slapper.AutoMapper/

Now let the slapping commence! 😃

  • .NETFramework 4.7

    • No dependencies.
  • .NETStandard 2.1

    • No dependencies.

NuGet packages (7)

Showing the top 5 NuGet packages that depend on Slapper.AutoMapper:

Package Downloads
DapperExtensions

A small library that complements Dapper by adding basic CRUD operations (Get, Insert, Update, Delete) for your POCOs. For more advanced querying scenarios, Dapper Extensions provides a predicate system.

Sharp

A set of utilities and a simple framework for turning methods into httpRequest end points.

Mir.Stf.Utilities.StfUtils

Mir Stf Utilities

NET.Database.QueryLayer

NET-Database query layer components will be a useful addition to any application or website to create SQL queries to your database in a OO way. It supports the majority of different database types such as SQL Server® MySQL® o PostgreSQL®, but is easy extend to any ADO.NET provider.

VMRCPACK.UOW.Dapper

This pack is Dapper Implementation

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Slapper.AutoMapper:

Repository Stars
tmsmith/Dapper-Extensions
Dapper Extensions is a small library that complements Dapper by adding basic CRUD operations (Get, Insert, Update, Delete) for your POCOs. For more advanced querying scenarios, Dapper Extensions provides a predicate system. The goal of this library is to keep your POCOs pure by not requiring any attributes or base class inheritance.
Version Downloads Last updated
2.0.5 4,438 9/22/2021
2.0.4 42,306 4/13/2021
2.0.3 293 4/13/2021
2.0.2 2,671 4/4/2021
2.0.1 169,098 6/20/2020
2.0.0 421 6/20/2020
1.0.0.9 411,034 6/12/2016
1.0.0.8 69,176 2/20/2016
1.0.0.7 16,357 1/16/2016
1.0.0.6 46,382 11/26/2013
1.0.0.5 999 11/15/2013
1.0.0.4 1,954 11/11/2013
1.0.0.3 809 11/7/2013
1.0.0.2 879 10/25/2013

Version 2.0.5 release
-Memory improvement (See Issue #83 - Thanks wegnerb)