Slapper.AutoMapper 2.0.5

dotnet add package Slapper.AutoMapper --version 2.0.5                
NuGet\Install-Package Slapper.AutoMapper -Version 2.0.5                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<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                
#r "nuget: Slapper.AutoMapper, 2.0.5"                
#r directive can be used in F# Interactive and Polyglot Notebooks. 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                

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! 😃

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
.NET Framework net47 is compatible.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.7

    • No dependencies.
  • .NETStandard 2.1

    • No dependencies.

NuGet packages (13)

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

Fanzoo.Kernel

An opinionated framework for building scalable web applications.

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.

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 630,539 9/22/2021
2.0.4 138,797 4/13/2021
2.0.3 1,894 4/13/2021
2.0.2 29,310 4/4/2021
2.0.1 1,555,012 6/20/2020
2.0.0 8,231 6/20/2020
1.0.0.9 665,992 6/12/2016
1.0.0.8 84,646 2/20/2016
1.0.0.7 19,524 1/16/2016
1.0.0.6 75,918 11/26/2013
1.0.0.5 2,291 11/15/2013
1.0.0.4 3,478 11/11/2013
1.0.0.3 2,064 11/7/2013
1.0.0.2 2,244 10/25/2013

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