Hydrogen.Repo
2.7.0-preview.1
See the version list below for details.
dotnet add package Hydrogen.Repo --version 2.7.0-preview.1
NuGet\Install-Package Hydrogen.Repo -Version 2.7.0-preview.1
<PackageReference Include="Hydrogen.Repo" Version="2.7.0-preview.1" />
<PackageVersion Include="Hydrogen.Repo" Version="2.7.0-preview.1" />
<PackageReference Include="Hydrogen.Repo" />
paket add Hydrogen.Repo --version 2.7.0-preview.1
#r "nuget: Hydrogen.Repo, 2.7.0-preview.1"
#:package Hydrogen.Repo@2.7.0-preview.1
#addin nuget:?package=Hydrogen.Repo&version=2.7.0-preview.1&prerelease
#tool nuget:?package=Hydrogen.Repo&version=2.7.0-preview.1&prerelease
Hydrogen Repo
This package uses SqlKata as query builder, if you have doubts check its documentation. Installation
dotnet add package Hydrogen.Repo dotnet add package Hydrogen.Repo.Abstractions
Models Create a model
[DeletedAt] //The deletion will be soft and not logical.
[Table("Users")] // Table name in the database.
public class User
{
[PrimaryKey] // Mark the property as the primary key.
[AutoGenerateGuid] // Indicate that it will be an auto-generated GUID field.
public Guid Id { get; set; }
public Guid RoleId { get; set; }
public string Email { get; set; } = string.Empty;
public string Password { get; set; } = string.Empty;
public bool TwoFactor { get; set; }
[CreatedAt] // Indicate that the property functions as a timestamp of when the element was created.
public DateTime CreatedAt { get; set; }
[UpdatedAt] // Indicate that the property functions as a timestamp of when the element was updated.
public DateTime UpdatedAt { get; set; }
}
Database context Create a database context interface
public interface IDatabaseContext : IHydrogenContext {
}
Create a class that implements the database context interface
public class DatabaseContext : HydrogenContext, IDatabaseContext { public DatabaseContext(IDbConnection connection, DbConnectionType connectionType, bool debug = false, Action<SqlResult>? action = null) : base(connection, connectionType, debug, action) { } }
Unit of work (optional) Create an interface for the unit of work
public interface IDatabaseUnitOfWork : IHydrogenUnitOfWork { }
Create a class that implements the unit of work interface
class DatabaseUnitOfWork : HydrogenUnitOfWork, IDatabaseUnitOfWork { public DatabaseUnitOfWork(IDatabaseContext DatabaseContext) : base(DatabaseContext) { } }
Repositories Create the repository interface
public interface IUserRepository : IHydrogenRepository<User, Guid> { // Add your functions }
Create a class that implements the repository interface
The repository already implements the basic functions.
public class UserRepository : HydrogenRepository<User, Guid>, IUserRepository { public UserRepository(IDatabaseContext databaseContext) : base(databaseContext) { } }
Add the implementations to the service collection
var connectionBuilder = new SqliteConnectionStringBuilder() { DataSource = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "test.db"), };
var connection = new SqliteConnection(connectionBuilder.ConnectionString);
collection.AddScoped<IDatabaseContext>(_ ⇒ new DatabaseContext(connection, DbConnectionType.SQLite, true)); collection.AddScoped<IDatabaseUnitOfWork, DatabaseUnitOfWork>(); collection.AddScoped<IUserRepository, UserRepository>();
Use it in a service
private readonly IUserRepository _userRepository;
public OptionService(IUserRepository userRepository) { _userRepository = userRepository; }
public async Task<IEnumerable<UserDto>> GetAllAsync(CancellationToken ct) { return _userRepository.GetAsync<UserDto>(ct); }
Available functions
Any
Count
Insert
Bulk insert
Bulk update
Update
Delete
Get
Pagination
First
First or default
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. net9.0 was computed. 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 was computed. 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
- Hydrogen.Repo.Abstractions (>= 2.7.0-preview.1)
- Newtonsoft.Json (>= 13.0.3)
- SqlKata (>= 2.4.0)
- SqlKata.Execution (>= 2.4.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
2.7.0-preview.2 | 136 | 9/16/2025 |
2.7.0-preview.1 | 138 | 9/16/2025 |
2.6.0 | 207 | 8/24/2025 |
2.6.0-preview.1 | 142 | 9/15/2025 |
2.4.0 | 209 | 8/7/2025 |
2.0.2 | 157 | 6/16/2025 |
2.0.1 | 172 | 6/14/2025 |
2.0.0 | 301 | 6/13/2025 |
1.8.2 | 286 | 6/10/2025 |
1.8.1 | 487 | 6/10/2025 |
1.6.2 | 141 | 12/20/2024 |
1.6.0 | 170 | 9/16/2024 |