OracleDbUtils 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package OracleDbUtils --version 1.0.0
                    
NuGet\Install-Package OracleDbUtils -Version 1.0.0
                    
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="OracleDbUtils" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OracleDbUtils" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="OracleDbUtils" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add OracleDbUtils --version 1.0.0
                    
#r "nuget: OracleDbUtils, 1.0.0"
                    
#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.
#:package OracleDbUtils@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=OracleDbUtils&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=OracleDbUtils&version=1.0.0
                    
Install as a Cake Tool

OracleDbUtils

OracleDbUtils is a .NET utility library that simplifies working with Oracle databases using Oracle.ManagedDataAccess.Core. It provides a clean abstraction layer for executing stored procedures, querying views/tables, and generating reports via Oracle Reports.

✨ Features

  • ✅ Easy execution of Oracle PL/SQL procedures and functions
  • ✅ Query tables and views with strongly-typed DTOs
  • ✅ Pagination support
  • ✅ Oracle Reports generation using HTTP API
  • ✅ Custom attribute-based mapping system

📦 Installation

Install via NuGet:

dotnet add package OracleDbUtils

🚀 Quick Start

1. Execute a PL/SQL Package Procedure

public class MyProcEntity : OracleEntity
{
    [OracleParameter("P_ID", OracleDbType.Int32)]
    public int Id { get; set; }

    public override void EnsureEntity()
    {
        if (Id <= 0)
            throw new OraException("600", "Id must be positive.");
    }
}

var entity = new MyProcEntity { Id = 123 };
var result = await dbContext.ExecutePackageAsync(entity, "MY_PACKAGE.MY_PROCEDURE");

2. Query a View or Table

public class EmployeeDto : OracleBaseDto
{
    [OracleField("EMP_ID", OracleDbType.Int32)]
    public int Id { get; set; }

    [OracleField("EMP_NAME", OracleDbType.Varchar2)]
    public string Name { get; set; } = string.Empty;
}

var employees = await dbContext.SelectViewAsync<EmployeeDto>(
    viewName: "EMPLOYEES_VIEW",
    conditions: new Dictionary<string, object> { ["DEPT_ID"] = 10 },
    orderBy: "EMP_NAME",
    pagination: new OraclePaginationDto(pageNumber: 0, pageSize: 10)
);

3. Generate an Oracle Report (PDF)

var reportRequest = new OracleReportRequest
{
    ReportName = "HR_REPORT.rdf",
    DestName = "output/report.pdf",
    Parameters = new Dictionary<string, object>
    {
        ["P_DEPT_ID"] = 10
    }
};

var reportService = new OracleReportService(); // implement IReportService
var reportBytes = await reportService.GenerateOracleReport(reportRequest);
File.WriteAllBytes("HR_Report.pdf", reportBytes);

🧱 Core Components

IDbContext

Interface to execute Oracle procedures and queries:

Task<T> ExecutePackageAsync<T>(T entity, string programUnitName) where T : OracleEntity;
Task<List<T>> SelectViewAsync<T>(string viewName, Dictionary<string, object> conditions, string? orderBy = null, OraclePaginationDto? pagination = null) where T : OracleBaseDto, new();
Task<T?> SelectSingleAsync<T>(string viewName, Dictionary<string, object> conditions) where T : OracleBaseDto, new();
Task<int> SelectViewCountAsync(string viewName, Dictionary<string, object> conditions);

OracleEntity

Base class for objects sent to stored procedures. Override EnsureEntity() for validation logic.

OracleBaseDto

Base class for data transfer objects (DTOs) mapped to views/tables.

OracleFieldAttribute

Maps class properties to Oracle view/table columns:

[OracleField("COLUMN_NAME", OracleDbType.Varchar2)]
public string PropertyName { get; set; }

OracleParameterAttribute

Maps class properties to procedure parameters with direction and size control:

[OracleParameter("P_NAME", OracleDbType.Varchar2, direction: ParameterDirection.Input)]
public string Name { get; set; }

OraclePaginationDto

Enforces pagination for view queries (PageNumber ≥ 0, PageSize ∈ [0, 25]).

OracleReportRequest

Model for defining Oracle report generation requests:

new OracleReportRequest
{
    ReportName = "MyReport.rdf",
    DestFormat = "pdf",
    Parameters = new Dictionary<string, object> { ["P_ID"] = 123 }
}

IReportService

Defines a service that returns the raw bytes of an Oracle report file.


⚠️ Pagination Rules

OraclePaginationDto enforces:

  • PageNumber ≥ 0
  • PageSize ∈ [0, 25]

Violations will throw OraException with code "602".


🔧 Requirements

  • .NET 6.0 or later
  • Oracle.ManagedDataAccess.Core (automatically included)
  • Access to Oracle Database
  • Optional: Oracle Reports server (HTTP-accessible)

📄 License

This project is licensed under the MIT License. See the LICENSE file for details.


💬 Feedback / Issues

Found a bug or want to request a feature?
Open an issue on GitHub


🙌 Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.


👀 Example Use Cases

  • Simplifying complex Oracle DB access in enterprise apps
  • Wrapping PL/SQL logic behind simple service calls
  • Building report export features in .NET backends

Product 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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on OracleDbUtils:

Package Downloads
OracleAuthLib

Authentication and authorization library for Oracle-based systems.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.6.6 185 8/8/2025
1.6.5 43 8/2/2025
1.6.4 45 8/2/2025
1.6.3 50 8/2/2025
1.6.2 42 8/2/2025
1.6.1 40 8/2/2025
1.6.0 44 8/2/2025
1.5.2 112 7/30/2025
1.5.1 112 7/30/2025
1.5.0 113 7/30/2025
1.4.3 103 7/27/2025
1.4.2 211 7/26/2025
1.4.1 211 7/26/2025
1.4.0 212 7/26/2025
1.3.4 226 7/26/2025
1.3.3 224 7/26/2025
1.3.2 146 7/1/2025
1.3.1 137 7/1/2025
1.3.0 147 6/2/2025
1.2.2 164 4/29/2025
1.2.1 142 4/29/2025
1.2.0 147 4/29/2025
1.1.0 113 4/12/2025
1.0.2 130 4/11/2025
1.0.1 143 4/11/2025
1.0.0 128 4/11/2025