JM.Oracle.Dapper.NetCore
1.0.0
See the version list below for details.
dotnet add package JM.Oracle.Dapper.NetCore --version 1.0.0
NuGet\Install-Package JM.Oracle.Dapper.NetCore -Version 1.0.0
<PackageReference Include="JM.Oracle.Dapper.NetCore" Version="1.0.0" />
paket add JM.Oracle.Dapper.NetCore --version 1.0.0
#r "nuget: JM.Oracle.Dapper.NetCore, 1.0.0"
// Install JM.Oracle.Dapper.NetCore as a Cake Addin #addin nuget:?package=JM.Oracle.Dapper.NetCore&version=1.0.0 // Install JM.Oracle.Dapper.NetCore as a Cake Tool #tool nuget:?package=JM.Oracle.Dapper.NetCore&version=1.0.0
JM.Oracle.Dapper.NetCore
Package to simplify the use of Oracle database in .Net Core projects. This package already implements the use of the micro ORM Dapper to make it even easier.
Getting Started
Nuget Package
(1) Create class inheriting from "Oracle Context" if working with multiple contexts.
using Oracle.Dapper.NetCore.Context;
namespace Oracle.Dapper.NetCore.Console.Example.Infra
{
public class MyDbContext : OracleContext
{
public MyDbContext(string connectionString)
: base(connectionString)
{
}
}
}
(2) Dependency Injection
Register oracle dependencies as scoped
services.AddScopedOracleDapper<MyDbContext>("<<CONNECTION_STRING>>");
Register oracle dependencies as transient - suitable for parallel and multi-thread executions
services.AddTransientOracleDapper<MyDbContext>("<<CONNECTION_STRING>>");
(3) Features
In the context, there are several resources for executing commands in the database, each one of them will be detailed below.
3.1) Connection
By default the connection is opened when instantiating the context, however there are methods below for opening and closing the connection.
//It has a policy that will make up to 3 attempts to connect to the database if necessary
_context.OpenOracleConnection();
_context.Open();
_context.Close();
3.2) Transactions
There are below methods for transaction control.
_context.BeginTransaction();
_context.CommitTransaction();
_context.RollbackTransaction();
//Get the current transaction (if it exists)
_context.CurrentTransaction
3.1) Database Commands
Contains available resources (synchronous and asynchronous) for executing commands in the database
_context.Database.
- _context is a instance of OracleContext
- Database is the property that makes resources available for executing commands in the database
list of methods present in [Database] |
---|
Execute |
ExecuteAsync |
ExecuteReader |
ExecuteReaderAsync |
ExecuteReaderWithReturnDbDataReaderAsync |
ExecuteScalar |
ExecuteScalarAsync |
Query |
QueryAsync |
QueryFirst |
QueryFirstAsync |
QueryFirstOrDefault |
QueryFirstOrDefaultAsync |
QueryMultiple |
QueryMultipleAsync |
QuerySingle |
QuerySingleAsync |
QuerySingleOrDefault |
QuerySingleOrDefaultAsync |
(3) Examples of use
A) Simple query execution
_context.Database.Query<string>("<sql query>");
B) Execution query with parameters
var parameters = new OracleDynamicParameters();
parameters.Add("PARAM_NAME", "VALUE OF PARAM", OracleMappingType.Varchar2);
return await _context.Database.QueryAsync<string>("<sql query>", parameters);
C) Procedure execution with transaction
var parameters = new OracleDynamicParameters();
parameters.Add("PARAM1", valueOfParam, OracleMappingType.Int32);
parameters.Add("OUTPUT_PARAM", null, OracleMappingType.RefCursor, ParameterDirection.Output);
_context.BeginTransaction();
var result = _context.Database.Query<CLASS_DTO>("PROCEDURE_NAME", parameters, _context.CurrentTransaction.Instance, commandType: CommandType.StoredProcedure);
_context.CommitTransaction();
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. 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. |
.NET Core | netcoreapp3.1 is compatible. |
-
.NETCoreApp 3.1
- Dapper (>= 2.0.123)
- Dapper.Oracle (>= 2.0.3)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 3.1.22)
- Oracle.ManagedDataAccess.Core (>= 2.12.0-beta3)
- Polly (>= 7.2.3)
-
net5.0
- Dapper (>= 2.0.123)
- Dapper.Oracle (>= 2.0.3)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 5.0.0)
- Oracle.ManagedDataAccess.Core (>= 2.12.0-beta3)
- Polly (>= 7.2.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.