huzcodes.Persistence
1.0.0
See the version list below for details.
dotnet add package huzcodes.Persistence --version 1.0.0
NuGet\Install-Package huzcodes.Persistence -Version 1.0.0
<PackageReference Include="huzcodes.Persistence" Version="1.0.0" />
paket add huzcodes.Persistence --version 1.0.0
#r "nuget: huzcodes.Persistence, 1.0.0"
// Install huzcodes.Persistence as a Cake Addin #addin nuget:?package=huzcodes.Persistence&version=1.0.0 // Install huzcodes.Persistence as a Cake Tool #tool nuget:?package=huzcodes.Persistence&version=1.0.0
huzcodes.Persistence
huzcodes.Persistence is a C# .NET 8 package designed to simplify data persistence operations for SQL and Oracle databases. It provides a set of functions for reading and inserting data, with support for both synchronous and asynchronous operations.
Installation
To install huzcodes.Persistence, use the following command in the Package Manager Console:
dotnet add package huzcodes.Persistence --version 1.0.0
Usage
To use huzcodes.Persistence, first inject the 'IDataProvider' interface into your class constructor. Then, you can use the provided functions to interact with your database.
Registering the Package
// Add the registration of persistence from inside huzcodes persistence plugin
builder.Services.AddPersistenceServices();
Reading Data Examples
SQL Reading Async Without Parameters
var data = await _dataProvider.LoadDataAsync<DataModel, dynamic>(readProcedureName, connectionStringKey, storageProvider: DataStorageProvider.Sql);
return Ok(data);
SQL Reading Async With Parameters
var parameter = new { Id = id };
var data = await _dataProvider.LoadDataAsync<DataModel, dynamic>(readProcedureName, connectionStringKey, parameter);
return Ok(data.FirstOrDefault());
Oracle Reading Async Without Parameters
var data = await _dataProvider.LoadDataAsync<DataModel, dynamic>(readProcedureName, connectionStringKey, storageProvider: DataStorageProvider.Oracle);
return Ok(data);
Oracle Reading Async With Parameters
var parameter = new OracleDynamicParameters();
parameter.Add("Id", id, OracleMappingType.Int32, ParameterDirection.Input);
parameter.Add("DataResult", OracleMappingType.RefCursor, ParameterDirection.Output);
var data = await _dataProvider.LoadDataAsync<DataModel, dynamic>(readProcedureName, connectionStringKey, parameter, DataStorageProvider.Oracle);
return Ok(data.FirstOrDefault());
Inserting Data Examples
SQL Inserting Async
var parameter = new
{
Id = dataModel.Id,
ProductCreationDate = dataModel.Date,
PriceWithoutTax = dataModel.PriceWithoutTax,
ProductName = dataModel.ProductName
};
await _dataProvider.ExecuteDataAsync(createProcedureName, parameter, connectionStringKey);
return Ok();
Oracle Inserting Async
var parameter = new OracleDynamicParameters();
parameter.Add("Id", dataModel.Id, OracleMappingType.Int32, ParameterDirection.Input);
parameter.Add("ProductCreationDate", dataModel.Date, OracleMappingType.Date, ParameterDirection.Input);
parameter.Add("PriceWithoutTax", dataModel.PriceWithoutTax, OracleMappingType.Decimal, ParameterDirection.Input);
parameter.Add("ProductName", dataModel.ProductName, OracleMappingType.Varchar2, ParameterDirection.Input);
await _dataProvider.ExecuteDataAsync(createProcedureName, parameter, connectionStringKey, storageProvider: DataStorageProvider.Oracle);
return Ok();
For more information on how to use huzcodes.Persistence, please refer to the API Package Tests.
Contributing
Contributions are welcome! Please fork the repository and submit a pull request.
License
This project is licensed under the MIT License - see the LICENSE.md file for details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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. |
-
net8.0
- Dapper (>= 2.1.28)
- Dapper.Oracle (>= 2.0.3)
- Microsoft.Data.SqlClient (>= 5.2.0)
- Oracle.EntityFrameworkCore (>= 8.21.121)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
huzcodes.Persistence is a C# .NET 8 package that simplifies data persistence operations for SQL and Oracle databases. It provides functions for reading and inserting data, with support for both synchronous and asynchronous operations.