Skip to content
Oracle support for Dapper Micro ORM.
C# PowerShell Shell PLSQL
Branch: master
Clone or download
Latest commit ecfcfd2 Jul 18, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.paket Adding .netstandard2.0 targets. May 3, 2018
doc
scripts Fixing issue #26 May 12, 2019
src Added bulk sql feature May 12, 2019
tools - Changed buildsystem from psake to cake Apr 12, 2019
.gitattributes Fixing encoding issue for AssemblyInfo.cs(hopefully) Jun 11, 2018
.gitignore - Changed buildsystem from psake to cake Apr 12, 2019
GitVersion.yml - Changed buildsystem from psake to cake Apr 12, 2019
LICENSE Initial commit Apr 24, 2018
README.md Typo fix Jul 17, 2019
appveyor.yml - Changed buildsystem from psake to cake Apr 12, 2019
build.cake
build.ps1 - Changed buildsystem from psake to cake Apr 12, 2019
build.sh - Changed buildsystem from psake to cake Apr 12, 2019
packages.config Releasing v1.0 Jun 11, 2018
releasenotes.md Added bulk sql feature May 12, 2019

README.md

Dapper.Oracle

Oracle support for Dapper Micro ORM.

Build status NuGet

Introduction

Dapper is a great tool if you want to write database-agnostic code. However, sometimes you need to access functionality that is provider-specific. This assembly adds support for writing Oracle-specific SQL, that supports all dbtypes used by the Oracle managed provider on a parameter, supports setting various properties on the command(LOBFetchSize, ArrayBindCount, BindByName), as well as setting CollectionType on the parameter. Using this package, you can now run stored procedures that returns RefCursor, or use array bind count to execute a sql statements with a array of parameters.

Supported Oracle-specific properties

OracleParameter(Managed and UnManaged)

  • OracleDbType enum (all members used by the managed provider)
  • CollectionType enum
  • ParameterStatus (return type when executing stored procedure)
  • ArrayBindSize

OracleCommand (Managed and UnManaged)

  • ArrayBindCount property
  • BindByName property
  • InitialLOBFetchSize (LOB = Large Object Binary)

Works with both Managed and Unmanaged driver

Dapper.Oracle uses reflection to set parameters on both the managed and unmanaged driver(ODP.Net), so it does not have any direct dependencies to a specific Oracle driver.
However, you still need to reference either Oracle.DataAccess or Oracle.ManagedDataAccess in addition to this package. Usage is pretty much like standard Dapper, see usage-section below.

Usage examples

public string RunStoredProcedure(string parametervalue1,string parametervalue2)
{
    var connection = new OracleConnection("mydatabaseconnectionstring");
    var parameters = new OracleDynamicParameters();
    parameters.Add("RETURN_VALUE", string.Empty, OracleMappingType.Varchar2, ParameterDirection.ReturnValue, 4000, true, 0, 0, string.Empty, DataRowVersion.Current);
    parameters.Add("PARAMETER1", parametervalue1, OracleMappingType.Varchar2, ParameterDirection.Input, 4000, true, 0, 0, String.Empty, DataRowVersion.Current);
    parameters.Add("PARAMETER2", parametervalue1, OracleMappingType.Xml, ParameterDirection.Input, 4000, true, 0, 0, string.Empty, DataRowVersion.Current);

    connection.Execute("Schema.Package.MyStoredProcedure", parameters, commandType: CommandType.StoredProcedure);

    return parameters.Get<string>("RETURN_VALUE");
}

public void RunStoredProcedureWithArrayAsParameters(IEnumerable<long> idvalues)
{
    var parameters = new OracleDynamicParameters();
    var idArray = idvalues.ToArray();
    parameters.ArrayBindCount = idArray.Count;

    parameters.Add("ArrayParameter", idArray, OracleMappingType.Int64, ParameterDirection.Input);
    connection.Execute("Schema.Package.MyStoredProcedure", parameters, commandType: CommandType.StoredProcedure);
}

Building

From a powershell script, run build.ps1 from the root folder of the repo.

Example:

build.ps1 -Task Compile
You can’t perform that action at this time.