OracleORM 1.0.6

dotnet add package OracleORM --version 1.0.6                
NuGet\Install-Package OracleORM -Version 1.0.6                
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.6" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add OracleORM --version 1.0.6                
#r "nuget: OracleORM, 1.0.6"                
#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.6

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

OracleORM Documentation body { font-family: Arial, sans-serif; line-height: 1.6; margin: 20px; } h1, h2, h3 { color: #333; } code { background-color: #f4f4f4; padding: 2px 4px; border-radius: 4px; } pre { background-color: #f4f4f4; padding: 10px; border-radius: 4px; overflow-x: auto; }

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, including dynamic query generation, mapping entities with custom attributes, and handling lazy query execution.

Features

  • Execute queries with and without parameters
  • Generate dynamic WHERE clauses
  • Retrieve single or multiple records
  • Handle custom data conversions using attributes
  • Support for non-database mapped properties using IsDatabaseColumn attribute
  • Lazy query execution with IAsyncEnumerable
  • Map entities with custom converters

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>("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>(string query) where T : new();
    

ExecuteQueryWithParametersAsync

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

protected virtual async Task<IEnumerable<T>> ExecuteQueryWithParametersAsync<T>(string query, Dictionary<string, object> parameters) where T : new();
    

ExecuteLazyQuery

Executes a query lazily and returns an IAsyncEnumerable<T>.

protected virtual async IAsyncEnumerable<T> ExecuteLazyQuery<T>(string query, CancellationToken cancellationToken = default) where T : new();
    

GetSingleRecordAsync

Retrieves a single record from the database.

protected virtual async Task<T?> GetSingleRecordAsync<T>(string query) where T : new();
    

GetRecordsByConditionAsync

Retrieves records based on a specific condition.

protected virtual async Task<IEnumerable<T>> GetRecordsByConditionAsync<T>(string tableName, string condition) where T : new();
    

GetAllRecordsAsync

Retrieves all records from a table.

protected virtual async Task<IEnumerable<T>> GetAllRecordsAsync<T>(string tableName) 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