OracleORM 1.0.3
See the version list below for details.
dotnet add package OracleORM --version 1.0.3
NuGet\Install-Package OracleORM -Version 1.0.3
<PackageReference Include="OracleORM" Version="1.0.3" />
paket add OracleORM --version 1.0.3
#r "nuget: OracleORM, 1.0.3"
// Install OracleORM as a Cake Addin #addin nuget:?package=OracleORM&version=1.0.3 // Install OracleORM as a Cake Tool #tool nuget:?package=OracleORM&version=1.0.3
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 | Versions 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. |
-
net8.0
- Oracle.ManagedDataAccess.Core (>= 23.5.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.