Izayoi.Data.DbDataMapper
1.2.0
dotnet add package Izayoi.Data.DbDataMapper --version 1.2.0
NuGet\Install-Package Izayoi.Data.DbDataMapper -Version 1.2.0
<PackageReference Include="Izayoi.Data.DbDataMapper" Version="1.2.0" />
<PackageVersion Include="Izayoi.Data.DbDataMapper" Version="1.2.0" />
<PackageReference Include="Izayoi.Data.DbDataMapper" />
paket add Izayoi.Data.DbDataMapper --version 1.2.0
#r "nuget: Izayoi.Data.DbDataMapper, 1.2.0"
#:package Izayoi.Data.DbDataMapper@1.2.0
#addin nuget:?package=Izayoi.Data.DbDataMapper&version=1.2.0
#tool nuget:?package=Izayoi.Data.DbDataMapper&version=1.2.0
Izayoi.Data.DbDataMapper
This is a fast micro O/R mapper (ORM) that stores data retrieved from a DB into any object.
Available Databases
A Database with a package that implements classes that inherit from the DbCommand and DbDataReader classes.
| Database | NuGet | GitHub | Project |
|---|---|---|---|
| MySQL | MySqlConnector | MySqlConnector | mysqlconnector.net |
| PostgreSQL | Npgsql | Npgsql | Npgsql |
| SQL Server | Microsoft.Data.Sqlclient | - | - |
| SQLite | Microsoft.Data.Sqlite | - | - |
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 9, 10 |
| .NET Standard | 2.1 |
| Unity | 2021, 2022, 6000 |
Wiki
Examples
Database
-- SQL Server Example
CREATE TABLE [dbo].[users] (
[id] INT IDENTITY (1, 1) NOT NULL,
[name] NVARCHAR (50) NOT NULL,
[age] TINYINT NOT NULL,
[gender] TINYINT NOT NULL,
[created_at] DATETIME2 (7) NOT NULL,
[updated_at] DATETIME2 (7) NOT NULL,
PRIMARY KEY CLUSTERED ([id] ASC)
);
Map class
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
//[Table("users")]
[Table("users", Schema = "dbo")]
public class User
{
[Key]
[Column("id")]
public int Id { get; set; }
[Column("name")]
public string Name { get; set; } = string.Empty;
[Column("age")]
public byte Age { get; set; }
[Column("gender")]
public GenderType Gender { get; set; }
[Column("created_at")]
public DateTime CreatedAt { get; set; }
[Column("updated_at")]
public DateTime UpdatedAt { get; set; }
[NotMapped]
public int IgnoreProperty { get; set; }
}
- If the
[Table]attribute is not defined, the class name is used as the table name. - If the
[Column]attribute is not defined, the property name is used as the column name. - If the
[NotMapped]attribute is defined, the property is excluded from the mapping. - The
[Key]attribute is set to the primary key, but is not used by theDbDataMapperalone. (It is used when combined with theDbCommandAdapterclass.)
DbDataMapper
using System.Collections.Generic;
using System.Threading.Tasks;
using Izayoi.Data;
using Microsoft.Data.SqlClient; // for SQL Server
//using Microsoft.Data.Sqlite; // for SQLite
//using MySqlConnector; // for MySQL
//using Npgsql; // for PostgreSQL
public class Example()
{
private readonly dbConnectionString;
private readonly DbDataMapper dbDataMapper = new();
public async Task Method(CancellationToken cancellationToken)
{
using SqlConnection dbConnection = new(dbConnectionString);
using SqlCommand dbCommand = dbConnection.CreateCommand();
dbConnection.Open();
List<User> users;
// Select method A
{
dbCommand.CommandText = "SELECT * FROM dbo.users";
using SqlDataReader dbDataReader = await dbCommand.ExecuteReaderAsync(cancellationToken);
users = await dbDataMapper.ReadToObjectsAsync<User>(dbDataReader, cancellationToken);
}
// Select method B
{
dbCommand.CommandText = "SELECT * FROM dbo.users";
users = await dbDataMapper.ExecuteQueryAsync<User>(dbCommand, cancellationToken);
}
// Select method C
{
users = await dbDataMapper.SelectAllAsync<User>(dbCommand, cancellationToken);
}
dbConnection.Close();
}
}
Remarks
Reuse a DbDataMapper object whenever possible.
For a better experience
This library really shines when used in conjunction with the Izayoi.Data.DbCommandAdapter.
Last updated: 24 November, 2025
Editor: Izayoi Jiichan
Copyright (C) 2024 Izayoi Jiichan. All Rights Reserved.
| 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 is compatible. 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. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| 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. |
-
.NETStandard 2.1
- System.ComponentModel.Annotations (>= 4.1.0)
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Izayoi.Data.DbDataMapper:
| Package | Downloads |
|---|---|
|
Izayoi.Data.DbCommandAdapter
This is a database operation support library that includes a fast micro O/R mapper (ORM). |
GitHub repositories
This package is not used by any popular GitHub repositories.