huzcodes.Persistence 1.0.0

There is a newer version of this package available.
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                
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="huzcodes.Persistence" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add huzcodes.Persistence --version 1.0.0                
#r "nuget: huzcodes.Persistence, 1.0.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.
// 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
1.3.1 120 9/7/2024
1.3.0 120 6/30/2024
1.2.0 166 4/5/2024
1.0.0 159 3/3/2024

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.