UEntity.EntityFrameworkCore.PostgreSQL 10.3.3

dotnet add package UEntity.EntityFrameworkCore.PostgreSQL --version 10.3.3
                    
NuGet\Install-Package UEntity.EntityFrameworkCore.PostgreSQL -Version 10.3.3
                    
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="UEntity.EntityFrameworkCore.PostgreSQL" Version="10.3.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="UEntity.EntityFrameworkCore.PostgreSQL" Version="10.3.3" />
                    
Directory.Packages.props
<PackageReference Include="UEntity.EntityFrameworkCore.PostgreSQL" />
                    
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 UEntity.EntityFrameworkCore.PostgreSQL --version 10.3.3
                    
#r "nuget: UEntity.EntityFrameworkCore.PostgreSQL, 10.3.3"
                    
#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 UEntity.EntityFrameworkCore.PostgreSQL@10.3.3
                    
#: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=UEntity.EntityFrameworkCore.PostgreSQL&version=10.3.3
                    
Install as a Cake Addin
#tool nuget:?package=UEntity.EntityFrameworkCore.PostgreSQL&version=10.3.3
                    
Install as a Cake Tool

This IEntityRepository interface represents a generic entity repository interface. This interface defines standard CRUD (Create, Read, Update, Delete) operations for interacting with entities in a database table and provides various methods for query operations.

Features:

Various Query Methods: Various query methods such as Get, GetAll, GetArray, etc. support operations such as filtering, sorting, tracking.

Asynchronous Operations: Methods ending with async can run asynchronously so that the thread is not blocked.

Query Results: Query methods return entity objects, usually of type T, or specific properties of those entity objects.

Dynamic Filtering: Filtering operations can be configured dynamically using LINQ expressions. Sorting and Tracking: Some methods take parameters to configure sorting or tracking behaviour.

Batch Operations: Batch operations such as AddRange, UpdateRange, DeleteRange can be used to manipulate entity objects in a collection.

Aggregate Operations: Sum, Average, LongCount, Min, Max, MinBy, MaxBy operations with async support.

Element Access: Single, SingleOrDefault, ElementAt, ElementAtOrDefault operations.

Set Operations: Distinct, Contains, Union, Intersect, Except, Concat, GroupBy operations.

This interface is often used to abstract the data access operations of entity classes and reduce dependencies. It allows database operations to be independently testable and improves the overall performance and readability of the code.

Examples


// Definition
public class Product : IEntity
{
    public int Id { get; set; }
    public string Name { get; set; } = null!;
    public decimal Price { get; set; }
    public bool IsActive { get; set; }
    public string Category { get; set; } = null!;
}

public interface IProductDal : IEntityRepository<Product, IEntity>
{

}

public class ProductDal(TestDbContext context) : EfEntityRepositoryBase<Product, TestDbContext, IEntity>(context), IProductDal
{

}

// Usage
public class ProductService(IProductDal productDal)
{
    // Counting the number of entities that match the specified filter
    int count = productDal.Count(e => e.IsActive);

    // Getting a single entity that matches the specified filter
    var entity = productDal.Get(e => e.Id == 1);

    // Getting all entities
    var allEntities = productDal.GetAll();

    // Getting an array of entities that match the specified filter and sorting them
    var sortedEntities = productDal.GetArray(filter: e => e.IsActive, sort: new EntitySortModel<Product> { Sort = x => x.Name });

    // Getting a paginated list of entities
    var paginatedList = productDal.GetListPaginate(page: 1, size: 10, filter: e => e.IsActive);

    // Adding a new entity to the repository
    var newEntity = new Product { Name = "New Entity" };
    productDal.Add(newEntity);

    // Updating an existing entity in the repository
    var existingEntity = productDal.Get(e => e.Id == 1);
    existingEntity.Name = "Updated Entity";
    productDal.Update(existingEntity);

    // Deleting an entity from the repository
    var entityToDelete = productDal.Get(e => e.Id == 2);
    productDal.Delete(entityToDelete);

    // Asynchronously counting the number of entities that match the specified filter
    var countAsync = await productDal.CountAsync(e => e.IsActive);

    // Asynchronously getting a single entity that matches the specified filter
    var entityAsync = await productDal.GetAsync(e => e.Id == 1);

    // Asynchronously getting all entities
    var allEntitiesAsync = await productDal.GetAllAsync();

    // Asynchronously getting an array of entities that match the specified filter and sorting them
    var sortedEntitiesAsync = await productDal.GetArrayAsync(filter: e => e.IsActive, sort: new EntitySortModel<Product> { Sort = x => x.Name });

    // Asynchronously getting a paginated list of entities
    var paginatedListAsync = await productDal.GetListPaginateAsync(page: 1, size: 10, filter: e => e.IsActive);

    // Asynchronously adding a new entity to the repository
    var newEntityAsync = new Product { Name = "New Entity" };
    await productDal.AddAsync(newEntityAsync);

    // Asynchronously updating an existing entity in the repository
    var existingEntityAsync = await productDal.GetAsync(e => e.Id == 1);
    existingEntityAsync.Name = "Updated Entity";
    await productDal.UpdateAsync(existingEntityAsync);

    // Asynchronously deleting an entity from the repository
    var entityToDeleteAsync = await productDal.GetAsync(e => e.Id == 2);
    await productDal.DeleteAsync(entityToDeleteAsync);

    // Asynchronously executing a delete operation on entities that match the specified filter
    await productDal.ExecuteDeleteAsync(x => x.Name.Contains("55"));

    // Asynchronously executing an update operation on entities that match the specified filter
    await productDal.ExecuteUpdateAsync(x => x.SetProperty(p => p.Name, p => "Updated"), x => x.Id == 11);

    // Aggregate Operations
    int totalCount = productDal.Count(x => x.IsActive);
    decimal totalSum = productDal.SumDecimal(x => x.IsActive, x => x.Price);
    decimal averagePrice = productDal.AverageDecimal(x => x.IsActive, x => x.Price);
    long longCount = productDal.LongCount(x => x.Price > 100);
    decimal maxPrice = productDal.Max(x => x.Price);
    decimal minPrice = productDal.Min(x => x.Price);
    var maxProduct = productDal.MaxBy(x => x.Price);
    var minProduct = productDal.MinBy(x => x.Price);

    // Single Operations
    var singleProduct = productDal.Single(x => x.Id == 1);
    var singleOrDefaultProduct = productDal.SingleOrDefault(x => x.Id == 999);

    // ElementAt Operations
    var secondProduct = productDal.ElementAt(1);
    var productAtOrDefault = productDal.ElementAtOrDefault(999);

    // Distinct
    var distinctCategories = productDal.Distinct(x => x.Category);

    // Contains
    bool exists = productDal.Contains(entity);

    // Set Operations
    var allProducts = productDal.GetAll();
    var union = productDal.Union(allProducts.AsQueryable());
    var intersect = productDal.Intersect(allProducts.AsQueryable());
    var except = productDal.Except(allProducts.AsQueryable());
    var concat = productDal.Concat(allProducts.AsQueryable());

    // GroupBy
    var grouped = productDal.GroupBy(x => x.Category);
    var groupedWithResult = productDal.GroupBy(
        x => x.Category,
        null,
        (key, items) => new { Category = key, Count = items.Count() });

    // Sorting with ThenBy
    var sorted = productDal.GetAll(
        sort: new EntitySortModel<Product>
        {
            Sort = x => x.Category,
            SortType = SortOrder.Ascending,
            ThenBy = x => x.Name,
            ThenBySortType = SortOrder.Ascending
        });

    // Expression Combiners
    var filter1 = new Expression<Func<Product, bool>>(x => x.IsActive);
    var filter2 = new Expression<Func<Product, bool>>(x => x.Price > 100);
    var combined = filter1.And(filter2);
    var combinedOr = filter1.Or(filter2);
}
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
10.3.3 41 6/14/2026
10.3.2 46 6/10/2026
10.3.1 40 6/10/2026
10.3.0 145 3/31/2026
10.2.0 230 11/25/2025
10.1.0 346 11/11/2025
10.0.1 107 3/31/2026
10.0.0 736 7/22/2025
9.0.4.10 116 2/24/2026
9.0.4.9 181 2/5/2026
9.0.4.8 454 12/11/2025
9.0.4.7 781 12/2/2025
9.0.4.6 702 12/2/2025
9.0.4.5 723 12/2/2025
9.0.4.4 374 11/30/2025
9.0.4.3 151 11/29/2025
9.0.4.2 309 5/5/2025
9.0.4.1 234 3/29/2025
9.0.4 197 3/29/2025
9.0.3 330 2/20/2025
Loading failed