Giter Site home page Giter Site logo

dapper.oracle's Introduction

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

dapper.oracle's People

Contributors

epaulsen avatar andmos avatar gaudico avatar hjerpbakk avatar wast avatar opejanovic avatar

Stargazers

MMustafaYILDIZ avatar

Watchers

James Cloos avatar MMustafaYILDIZ avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.