MapDataReader 1.0.3
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package MapDataReader --version 1.0.3
NuGet\Install-Package MapDataReader -Version 1.0.3
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="MapDataReader" Version="1.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MapDataReader --version 1.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: MapDataReader, 1.0.3"
#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 MapDataReader as a Cake Addin #addin nuget:?package=MapDataReader&version=1.0.3 // Install MapDataReader as a Cake Tool #tool nuget:?package=MapDataReader&version=1.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
MapDataReader
Super fast mapping DataReader to a strongly typed object. High performance, lighweight (12Kb dll), uses AOT source generation and no reflection, mapping code is generated at compile time.
Benchmarks
20X faster than using reflection, even with caching. Benchmark for a tiny class with 5 string properties:
Method | Mean | Error | StdDev | Gen0 | Allocated |
---|---|---|---|---|---|
Reflection | 951.16 ns | 15.107 ns | 0.828 ns | 0.1459 | 920 B |
MapDataReader | 44.15 ns | 2.840 ns | 0.156 ns | 0.0089 | 56 B |
Install via Nuget
Install-Package MapDataReader
Usage
using MapDataReader;
[GenerateDataReaderMapper] // <-- mark your class with this attribute
public class MyClass
{
public int ID { get; set; }
public string Name { get; set; }
public int Size { get; set; }
public bool Enabled { get; set; }
}
//ToMyClass() method code is generated at compile time
List<MyClass> result = dbconnection.ExecuteReader("SELECT * FROM MyTable").ToMyClass();
Some notes
- The
ToMyClass()
method above - is an extension method generated at compile time. You can even "go to definition" in Visual Studio and examine its code. - The naming convention is
ToCLASSNAME()
we can't use generics here, since<T>
is not part of method signatures in C# (considered in later versions of C#). - Maps properies with public setters only.
- The reader is being closed after mapping, so don't reuse it.
- The example above uses
.ExecuteReader
method from Dapper, but you can generate the reader in any way you want, e.g. the plainSqlCommand.ExecuteReader
will also work. - Supports
enum
properties based onint
and other implicit casting (sometimes a DataReader may decide to returnbyte
for small integer database value, and it maps toint
perfectly via some unboxing magic) - Properly maps
DBNull
tonull
. - Complex-type properties may not work.
- netstandard 2.0
- Contributions are very welcome.
Product | Versions 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 | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. 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 | tizen40 was computed. 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.
-
.NETStandard 2.0
- Microsoft.CodeAnalysis.CSharp (>= 4.3.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on MapDataReader:
Package | Downloads |
---|---|
Thelegend107.SQL.Data.Lib
TheLegend107 SQL Database library. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.13 | 5,396 | 5/1/2024 |
1.0.12 | 145 | 4/26/2024 |
1.0.11 | 9,435 | 5/5/2023 |
1.0.10 | 9,100 | 1/20/2023 |
1.0.9 | 418 | 1/8/2023 |
1.0.8 | 3,280 | 11/28/2022 |
1.0.6 | 503 | 11/1/2022 |
1.0.5 | 403 | 10/28/2022 |
1.0.4 | 2,073 | 10/24/2022 |
1.0.3 | 661 | 10/13/2022 |
1.0.2 | 424 | 10/11/2022 |
1.0.1 | 425 | 10/10/2022 |
1.0.0 | 422 | 10/10/2022 |