Library.NET.DataAccess 2022.4.5.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Library.NET.DataAccess --version 2022.4.5.1                
NuGet\Install-Package Library.NET.DataAccess -Version 2022.4.5.1                
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="Library.NET.DataAccess" Version="2022.4.5.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Library.NET.DataAccess --version 2022.4.5.1                
#r "nuget: Library.NET.DataAccess, 2022.4.5.1"                
#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 Library.NET.DataAccess as a Cake Addin
#addin nuget:?package=Library.NET.DataAccess&version=2022.4.5.1

// Install Library.NET.DataAccess as a Cake Tool
#tool nuget:?package=Library.NET.DataAccess&version=2022.4.5.1                

Library.NET.DataAccess

Implementing ISqlDataAccess & IOdbcDataAccess

Set the StoredConnectionString:

StoredConnectionString

StoredConnectionString.SetConnectionString("Driver={IBM i Access ODBC Driver};System=AS400;TRANSLATE=1;SIGNON=4;SSL=1");

Create a new instance:

IOdbcDataAccess odbcDataAccess = new OdbcDataAccess();

Get the data:

var records = odbcDataAccess.GetData<int>("SELECT COUNT(*) FROM library.member");
Console.WriteLine("Result:" + records.FirstOrDefault());

Result: 100

Implementing ICustomLogger (Optional)

You can use logging via the ICustomLogger (Library.NET.Logging) that comes with this package.

Use:

ICustomLogger logger = new CustomLogger(new FileInfo("logfile.log"), true, LogLevel.Information);

You can then add it to DI as a singleton.

Methods

Options:

  • queryOrStoredProcedure: Full query or Stored Procedure Name
  • connectionString(optional): Connection string for the query. Defaults to StoredConnectionString.ConnectionString.
  • parameters(optional): Parameters for the stored procedure. Type can be either Dapper.DynamicParameter or Dictionary<string, object>. Defaults to null.
  • isStoredProcedure(optional): Boolean confirming whether queryOrStoredProcedure is a stored procedure. Defaults to false.
  • commandTimeout(optional): How long before the query times out in seconds. Defaults to null

GetData & GetDataAsync

var model = sqlDataAccess.GetData<MODELorTYPE, Dictionary<string, object>>(queryOrStoredProcedure, connectionString, parameters, isStoredProcedure, commandTimeout);
var records = sqlDataAccess.GetData<TableNameModel>("QueryString", "[Full Connection String]", false, 60);
var asyncRecords = await sqlDataAccess.GetDataAsync<TableNameModel>("sp_TableNameGetAll", StoredConnectionString.ConnectionString, true, 60 );
var parameterRecords = sqlDataAccess.GetData<MODELorTYPE, Dictionary<string, object>("sp_TableNameGetByParameters", connString, parameters, true)

PostData, PostDataAsync, PutData, PutDataAsync, DeleteData, & DeleteDataAsync

int recordsAffected = sqlDataAccess.PostData(queryOrStoredProcedure, connectionString, isStoredProcedure, commandTimeout);
int recordsAffected = sqlDataAccess.PutData("QueryString", "[Full Connection String]", false, 60);
int recordsAffected = await sqlDataAccess.DeleteDataAsync("sp_TableNameDeleteAll", StoredConnectionString.ConnectionString, true, 60 );
int recordsAffected = sqlDataAccess.PostData<Dictionary<string, object>("sp_TableNamePostByParameters", connString, parameters, true)

PostDataTransactionAsync & PostDataTransactionForEachAsync

int recordsAffected = await sqlDataAccess.PostDataTransactionAsync("QueryString", connectionString, parameters, customLogger, isStoredProcedure, commandTimeout);

These are different since, instead of Posting all at once, they are transactional, so not all have to pass field restrictions in order for the process to work.

PostDataTransactionAsync & PostDataTransactionForEachAsync Options:

Same as above with the exception of:

  • customLogger: Will note Posts that did not succeed.

Planned implementations

  • MySql
  • MongoDb
  • PostgreSQL

Outside Dependencies

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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. 
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
2023.11.18.1 264 11/18/2023
2022.8.21.1 415 8/22/2022
2022.6.2.1 433 6/2/2022
2022.4.5.1 450 4/5/2022
2022.4.4.1 429 4/4/2022