OracleORM 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package OracleORM --version 1.0.0                
NuGet\Install-Package OracleORM -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="OracleORM" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add OracleORM --version 1.0.0                
#r "nuget: OracleORM, 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.
// Install OracleORM as a Cake Addin
#addin nuget:?package=OracleORM&version=1.0.0

// Install OracleORM as a Cake Tool
#tool nuget:?package=OracleORM&version=1.0.0                

OracleORM

OracleORM

OracleORM is a lightweight and flexible library for performing read operations on an Oracle database using C#. This library provides various utility methods to facilitate querying and retrieving data from the database.

Features

  • Execute queries with and without parameters
  • Generate dynamic WHERE clauses
  • Retrieve single or multiple records
  • Handle custom data conversions using attributes

Installation

To use OracleORM, simply include the source files in your project.

Usage

Setting Up

Create a repository class that inherits from OracleRepository:

public class MyRepository : OracleRepository
{
    public MyRepository(string connectionString) : base(connectionString) { }
}

Example Models

Define your models with the OracleAttributes attribute:

using OracleORM.Attributes;
using System;

public class Town
{
    [OracleAttributes("TOWN_ID", false)]
    public int Id { get; set; }

    [OracleAttributes("TOWN_NAME", false)]
    public string Name { get; set; } = default!;

    [OracleAttributes("ZIP_CODE", false)]
    public string ZipCode { get; set; } = default!;
}

Example Usage

Initialize Repository
var repository = new MyRepository("your_connection_string");
Execute Query
var zipCodes = new List<string> { "12345", "67890", "54321" };
var columnName = "ZipCode";
var whereClause = repository.GenerateDynamicWhere(zipCodes, columnName);

var query = repository.GenerateSelectQuery("Towns", whereClause);
var towns = await repository.GetRecordsByConditionAsync<Town>(repository.GetConnection(), "Towns", whereClause);

foreach (var town in towns)
{
    Console.WriteLine($"{town.Name} - {town.ZipCode}");
}

Methods

GenerateDynamicWhere

Generates a dynamic WHERE clause based on a list of values.

protected string GenerateDynamicWhere<T>(IEnumerable<T> values, string columnName);

ExecuteQueryAsync

Executes a query and returns a list of records.

protected virtual async Task<IEnumerable<T>> ExecuteQueryAsync<T>(OracleConnection connection, string query, bool closeConnection = false) where T : new();

ExecuteQueryWithParametersAsync

Executes a query with parameters and returns a list of records.

protected virtual async Task<IEnumerable<T>> ExecuteQueryWithParametersAsync<T>(OracleConnection connection, string query, Dictionary<string, object> parameters, bool closeConnection = false) where T : new();

GetSingleRecordAsync

Retrieves a single record from the database.

protected virtual async Task<T?> GetSingleRecordAsync<T>(OracleConnection connection, string query, bool closeConnection = false) where T : new();

GetRecordsByConditionAsync

Retrieves records based on a specific condition.

protected virtual async Task<IEnumerable<T>> GetRecordsByConditionAsync<T>(OracleConnection connection, string tableName, string condition, bool closeConnection = false) where T : new();

GetAllRecordsAsync

Retrieves all records from a table.

protected virtual async Task<IEnumerable<T>> GetAllRecordsAsync<T>(OracleConnection connection, string tableName, bool closeConnection = false) where T : new();

GenerateSelectQuery

Generates a SELECT query dynamically.

protected string GenerateSelectQuery(string tableName, string whereClause = "");

License

This project is licensed under the MIT License.

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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
1.0.6 74 8/31/2024
1.0.5 67 8/31/2024
1.0.4 66 8/31/2024
1.0.3 64 8/31/2024
1.0.2 73 8/29/2024
1.0.1 73 8/29/2024
1.0.0 74 8/29/2024