Kuwait.Lis.Common.Data 2.0.1

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package Kuwait.Lis.Common.Data --version 2.0.1
                    
NuGet\Install-Package Kuwait.Lis.Common.Data -Version 2.0.1
                    
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="Kuwait.Lis.Common.Data" Version="2.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Kuwait.Lis.Common.Data" Version="2.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Kuwait.Lis.Common.Data" />
                    
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 Kuwait.Lis.Common.Data --version 2.0.1
                    
#r "nuget: Kuwait.Lis.Common.Data, 2.0.1"
                    
#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 Kuwait.Lis.Common.Data@2.0.1
                    
#: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=Kuwait.Lis.Common.Data&version=2.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Kuwait.Lis.Common.Data&version=2.0.1
                    
Install as a Cake Tool

Kuwait.Lis.Common.Data

A .NET library providing common data access utilities for Kuwait LIS services.

Features

  • Repository Pattern: Generic repository implementation with Dapper
  • Database Connection Factory: SQL Server connection management
  • Base Entity: Common entity base class with audit fields
  • Stored Procedure Mapping: Parameter mapping helpers for stored procedures
  • OData Translation: Convert OData query syntax to SQL
  • Specification Pattern: Query specification support with Ardalis.Specification

Installation

Install the package via NuGet Package Manager:

dotnet add package Kuwait.Lis.Common.Data

Or via Package Manager Console:

Install-Package Kuwait.Lis.Common.Data

Usage

Repository Pattern

using Kuwait.Lis.Common.Data;

// Register in DI container
services.AddScoped<IDbConnectionFactory, SqlConnectionFactory>();
services.AddScoped<IRepository<MyEntity>, DapperRepository<MyEntity>>();

// Use in your service
public class MyService
{
    private readonly IRepository<MyEntity> _repository;
    
    public MyService(IRepository<MyEntity> repository)
    {
        _repository = repository;
    }
    
    public async Task<MyEntity> GetByIdAsync(int id)
    {
        return await _repository.GetByIdAsync(id);
    }
    
    public async Task<IEnumerable<MyEntity>> GetAllAsync()
    {
        return await _repository.GetAllAsync();
    }
}

Database Connection Factory

using Kuwait.Lis.Common.Data;

var connectionFactory = new SqlConnectionFactory("your-connection-string");
using var connection = connectionFactory.CreateConnection();

Base Entity

using Kuwait.Lis.Common.Data.Entities;

public class MyEntity : BaseEntity
{
    public string Name { get; set; }
    public string Description { get; set; }
    // CreatedDate, UpdatedDate, IsActive inherited from BaseEntity
}

Stored Procedure Parameter Mapping

using Kuwait.Lis.Common.Data.Helpers;

var parameters = StoredProcParamMapper.MapToParameters(myEntity);

OData Translation

using Kuwait.Lis.Common.Data;

// Convert OData filter to SQL WHERE clause
string odataFilter = "Name eq 'John' and Age gt 25";
string sqlWhere = ODataTranslator.TranslateFilter(odataFilter);
// Result: "Name = 'John' AND Age > 25"

// Convert OData orderby to SQL ORDER BY clause
string odataOrderBy = "Name asc, Age desc";
string sqlOrderBy = ODataTranslator.TranslateOrderBy(odataOrderBy);
// Result: "Name ASC, Age DESC"

Configuration

Add the following configuration to your appsettings.json:

{
  "ConnectionStrings": {
    "DefaultConnection": "Server=your-server;Database=your-database;Trusted_Connection=true;"
  }
}

Build and Package

To build the project and create NuGet package:

# Build the project
dotnet build --configuration Release

# Create NuGet package
dotnet pack --configuration Release --output ./packages

# Push to NuGet (optional)
dotnet nuget push ./packages/Kuwait.Lis.Common.Data.1.0.0.nupkg --api-key YOUR_API_KEY --source https://api.nuget.org/v3/index.json

Dependencies

  • .NET 9.0
  • Ardalis.Specification (8.0.0)
  • Dapper (2.1.35)
  • Microsoft.Data.SqlClient (5.2.2)
  • Microsoft.Extensions.DependencyInjection.Abstractions (9.0.0)

License

MIT License

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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

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