Izayoi.Data.Repository
1.2.0
.NET 8.0
This package targets .NET 8.0. The package is compatible with this framework or higher.
.NET Standard 2.1
This package targets .NET Standard 2.1. The package is compatible with this framework or higher.
dotnet add package Izayoi.Data.Repository --version 1.2.0
NuGet\Install-Package Izayoi.Data.Repository -Version 1.2.0
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="Izayoi.Data.Repository" Version="1.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Izayoi.Data.Repository" Version="1.2.0" />
<PackageReference Include="Izayoi.Data.Repository" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Izayoi.Data.Repository --version 1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Izayoi.Data.Repository, 1.2.0"
#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.
#:package Izayoi.Data.Repository@1.2.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Izayoi.Data.Repository&version=1.2.0
#tool nuget:?package=Izayoi.Data.Repository&version=1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Izayoi.Data.Repository
This is a database operation repository infrastructure with CRUD functionality.
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. It is used for update or delete methods.
Repository Class
using Izayoi.Data;
using Izayoi.Data.Query;
using Izayoi.Data.Repository;
public class UserRepository : DbRepositoryBase<User, int> // <MapClass, KeyDataType>
{
public UserRepository(IDbDataMapper dbDataMapper, QueryOption queryOption)
: base(dbDataMapper, queryOption) { }
public UserRepository(IDbCommandAdapter dbCommandAdapter)
: base(dbCommandAdapter) { }
}
Example Class
using System.Collections.Generic;
using System.Threading.Tasks;
using Izayoi.Data;
using Izayoi.Data.Query;
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 string dbConnectionString;
private readonly DbCommandAdapter dbCommandAdapter;
private readonly DbDataMapper dbDataMapper;
private readonly QueryOption queryOption;
private readonly UserRepository userRepository;
public Example()
{
queryOption = new QueryOption(RdbKind.SqlServer);
dbDataMapper = new DbDataMapper();
dbCommandAdapter = new DbCommandAdapter(dbDataMapper, queryOption);
userRepository = new UserRepository(dbCommandAdapter);
}
public async Task Method1(CancellationToken cancellationToken)
{
using SqlConnection dbConnection = new(dbConnectionString);
dbConnection.Open();
List<User> users = await userRepository.FetchAllAsync(dbConnection, cancellationToken);
User? user = await userRepository.FetchAsync(dbConnection, id: 1, cancellationToken);
dbConnection.Close();
}
public async Task Method2(CancellationToken cancellationToken)
{
using SqlConnection dbConnection = new(dbConnectionString);
dbConnection.Open();
var user = new User()
{
Id = 0,
Name = "name1",
Age = 20,
Gender = GenderType.Male,
CreatedAt = DateTime.UtcNow,
UpdatedAt = DateTime.UtcNow,
};
int affectedRowCount;
affectedRowCount = await userRepository.InsertReturnAsync(dbConnection, user, cancellationToken);
user.Age = 21;
user.UpdateAt = DateTime.UtcNow;
affectedRowCount = await userRepository.UpdateAsync(dbConnection, user, cancellationToken);
affectedRowCount = await userRepository.DeleteAsync(dbConnection, user, cancellationToken);
dbConnection.Close();
}
}
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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.1
- Izayoi.Data.DbCommandAdapter (>= 1.3.0)
-
net10.0
- Izayoi.Data.DbCommandAdapter (>= 1.3.0)
-
net8.0
- Izayoi.Data.DbCommandAdapter (>= 1.3.0)
-
net9.0
- Izayoi.Data.DbCommandAdapter (>= 1.3.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.