Library.NET.DataAccess
2023.11.18.1
dotnet add package Library.NET.DataAccess --version 2023.11.18.1
NuGet\Install-Package Library.NET.DataAccess -Version 2023.11.18.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="2023.11.18.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Library.NET.DataAccess --version 2023.11.18.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Library.NET.DataAccess, 2023.11.18.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=2023.11.18.1 // Install Library.NET.DataAccess as a Cake Tool #tool nuget:?package=Library.NET.DataAccess&version=2023.11.18.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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 NameconnectionString
(optional): Connection string for the query. Defaults toStoredConnectionString.ConnectionString
.parameters
(optional): Parameters for the stored procedure. Type can be eitherDapper.DynamicParameter
orDictionary<string, object>
. Defaults tonull
.isStoredProcedure
(optional): Boolean confirming whetherqueryOrStoredProcedure
is a stored procedure. Defaults tofalse
.commandTimeout
(optional): How long before the query times out in seconds. Defaults tonull
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
- MongoDb
- PostgreSQL
Outside Dependencies
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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Dapper (>= 2.1.21)
- Library.NET.Logging (>= 2023.11.18.1)
- Microsoft.Data.SqlClient (>= 5.1.2)
- MySql.Data (>= 8.2.0)
- System.Data.Odbc (>= 8.0.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 |
---|---|---|
2023.11.18.1 | 273 | 11/18/2023 |
2022.8.21.1 | 423 | 8/22/2022 |
2022.6.2.1 | 441 | 6/2/2022 |
2022.4.5.1 | 458 | 4/5/2022 |
2022.4.4.1 | 439 | 4/4/2022 |