Simple C# SqlDataReader object mapper. Allows you to map a SqlDataReader to the particular class.
Supports simple property mapping, property name transformations, string trimming, manual property binding by name, type changing, function binding, etc.
You should install SqlDataReaderMapper:
PM> Install-Package SqlDataReaderMapper
Or via the .NET Core command line interface:
PM> dotnet add package SqlDataReaderMapper
Either commands, from Package Manager Console or .NET Core CLI, will download and install SqlDataReaderMapper and all required dependencies.
Then, use the library in the project:
using SqlDataReaderMapper;
Here is an example of the usage:
var mappedObject = new SqlDataReaderMapper<UserDto>(reader)
.NameTransformers("_", "")
.IgnoreAllNonExisting()
.ForMember<int>("CurrencyId")
.ForMember("CurrencyCode", "Code")
.ForMember<string>("CreatedByUser", "User").Trim()
.ForMemberManual("CountryCode", val => val.ToString().Substring(0, 10))
.ForMemberManual("ZipCode", val => val.ToString().Substring(0, 5), "ZIP")
.Build();
Or simply:
var mappedObject = new SqlDataReaderMapper<UserDto>(reader)
.Build();
Copyright © 2019 Grigory and contributors.
SqlDataReaderMapper is licensed under GPL-3.0. Refer to LICENSE for more information.
I'm planning to make this library static.