EliazinyDB 1.0.0

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

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

EliazinyDB Library

EliazinyDB is a comprehensive data management library that provides robust repository implementations for various databases, including MySQL, MongoDB, and SQLite. It includes utilities for time management, custom exceptions for handling specific error scenarios, and attributes for database indexing and filtering.

Features

  • Repository Pattern: Provides a generic repository pattern for MySQL, MongoDB, and SQLite databases.
  • Custom Exceptions: Includes InputException and IntegrityException for better error handling.
  • Time Utilities: Utilities for managing Unix timestamps and getting the current date and time in various formats.
  • Attributes: Custom attributes for database indexing and filtering.
  • Dependency Injection: Easy setup with .NET Core Dependency Injection.

Getting Started

Prerequisites

  • .NET Core 3.1 or later
  • MongoDB, MySQL, or SQLite database

Installation

Add the EliazinyDB library to your project by including it in your .csproj file:

<PackageReference Include="EliazinyDB" Version="1.0.0" />

Or install via the .NET CLI:

dotnet add package EliazinyDB --version 1.0.0

Configuration

MySQL Repository
using EliazinyDB;
using EliazinyDB.Repositories;
using Microsoft.Extensions.DependencyInjection;

public void ConfigureServices(IServiceCollection services)
{
    services.ConfigureMySQLRepositoryClient<MySQLRepository>(
        dBCommand: new MySQLDBCommand(),
        mapper: new MapperConfiguration(cfg => cfg.AddProfile<MappingProfile>()).CreateMapper(),
        serviceLifetime: ServiceLifetime.Singleton
    );
}
MongoDB Repository
using EliazinyDB;
using EliazinyDB.Repositories;
using Microsoft.Extensions.DependencyInjection;

public void ConfigureServices(IServiceCollection services)
{
    services.ConfigureMongoDBRepositoryClient<MongoDBRepository>(
        mongoDB: new MongoDBClient(),
        serviceLifetime: ServiceLifetime.Singleton
    );
}
SQLite Repository
using EliazinyDB;
using EliazinyDB.Repositories;
using Microsoft.Extensions.DependencyInjection;

public void ConfigureServices(IServiceCollection services)
{
    services.ConfigureSQLiteRepositoryClient<SQLiteRepository>(
        dBCommand: new SQLiteDBCommand(),
        mapper: new MapperConfiguration(cfg => cfg.AddProfile<MappingProfile>()).CreateMapper(),
        serviceLifetime: ServiceLifetime.Singleton
    );
}

Usage

Example Repository Implementation

using EliazinyDB.Repositories;
using EliazinyDB.DTOs;

public class UserRepository : MySQLRepository
{
    public UserRepository(IDBCommand dBCommand, IMapper mapper) : base(dBCommand, mapper) { }

    public async Task<User> GetUserById(int id)
    {
        var result = await selectFromQuery<User>("SELECT * FROM Users WHERE Id = @Id", new List<object> { id });
        return result.resultAsObject.FirstOrDefault();
    }
}

Time Utilities

using EliazinyDB.Utils;

long timestamp = TimeUtils.GetTimeStamp(2024, 7, 9);
var todayDate = TimeUtils.GetTodayDate();
Console.WriteLine($"Unix Timestamp: {timestamp}, Today's Date: {todayDate.modernDate}");

Tests

The library includes unit tests using NUnit for validating repository functionality. You can run these tests using the following command:

dotnet test

Suggestions for Improvement

  • Error Handling: Enhance error handling to provide more specific exceptions and logging.
  • Expand Repository Functionality: Add support for additional database operations and features.

Contributions

Contributions to EliazinyDB are welcome! Please fork the repository, make your changes, and submit a pull request for review.

License

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

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.0 58 7/11/2024