Ozcorps.Generic 9.0.0

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

Ozcorps.Generic

.NET 8.0 NuGet Version License: MIT

Generic repository, unit-of-work, service, and CRUD controller base classes for ASP.NET Core with Entity Framework Core. Includes support for spatial queries, Snowflake IDs, soft-delete, audit fields, and optimistic concurrency versioning.

Installation

dotnet add package Ozcorps.Generic
<PackageReference Include="Ozcorps.Generic" Version="9.0.0" />

Core Concepts

Building Block Description
EntityBase<TId> Abstract base class for all entities
IRepository<T, TId> Generic data-access interface
IUnitOfWork Coordinates repositories and saves changes
EntityService<T, TId, TUserId> Business logic layer with CRUD, pagination, and spatial support
CrudController<T, TId, TUserId> Ready-made HTTP endpoints wired to EntityService
OzValueGenerator EF Core value generator backed by a DB sequence (PostgreSQL / MSSQL)
SnowflakeValueGenerator EF Core value generator that produces distributed Snowflake IDs

Entity Setup

1. Define your entity

using Ozcorps.Generic.Entity;

public class Product : EntityBase, IModifiedEntity
{
    public string Name { get; set; } = string.Empty;
    public decimal Price { get; set; }

    // IModifiedEntity
    public bool IsActive { get; set; }
    public bool IsDeleted { get; set; }
    public DateTime CreatedAt { get; set; }
    public DateTime? UpdatedAt { get; set; }
    public long CreatedById { get; set; }
    public long? UpdatedById { get; set; }
}

2. Entity interfaces

Interface Properties
IModifiedEntity<TUserId> IsActive, IsDeleted, CreatedAt, UpdatedAt, CreatedById, UpdatedById
IInsertedEntity<TUserId> CreatedAt, CreatedById
IVersionedEntity Version (optimistic concurrency via long?)

EntityService automatically populates audit fields and checks soft-delete when the entity implements these interfaces.

Repository & Unit of Work

// Resolve a typed repository
IRepository<Product> repo = unitOfWork.GetRepository<Product>();

// Common operations
Product? product    = repo.Get(id);
IQueryable<Product> all = repo.GetQueryable();

repo.Add(product);
repo.Remove(id);
unitOfWork.Save();

EntityService

EntityService<T, TId, TUserId> provides full CRUD, pagination, and spatial intersection out of the box.

public class ProductService : EntityService<Product, long, long>, IProductService
{
    public ProductService(IUnitOfWork unitOfWork) : base(unitOfWork) { }
}

Operations

Method Description
Get(TId id) Fetch by ID (respects soft-delete if IModifiedEntity)
Add(AddEntityDto dto, TUserId userId) Create from dynamic column map
Update(UpdateEntityDto<TId> dto, TUserId userId) Patch from dynamic column map
Remove(TId id, TUserId userId) Soft-delete or hard-delete
Any(TId id) Check existence
Intersect(string wkt) Spatial intersection query (WKT geometry)
Paginate(PaginatorDto dto) Dynamic filtering, sorting, and paging

CrudController

Inherit CrudController to get wired-up HTTP endpoints with zero boilerplate.

[ApiController]
[Route("api/[controller]")]
public class ProductController : CrudController<Product, long, long>
{
    public ProductController(IEntityServiceProvider provider, ILogger<ProductController> logger)
        : base(provider, logger) { }

    protected override long GetCurrentUserId() =>
        long.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier)!);
}

Generated endpoints

Verb Route Description
GET /{id} Fetch single entity
POST / Create from AddEntityDto
PUT / Update from UpdateEntityDto
DELETE /{id} Delete entity
GET /paginate Paginated list
GET /intersect Spatial intersection

Value Generators

OzValueGenerator — Database sequences

// In OnModelCreating:
modelBuilder.Entity<Product>()
    .Property(x => x.Id)
    .HasValueGenerator((_, __) =>
        new OzValueGenerator("product_id_seq", typeof(long), SequenceDbType.POSTGRE));

SnowflakeValueGenerator — Distributed IDs

modelBuilder.Entity<Order>()
    .Property(x => x.Id)
    .HasValueGenerator<SnowflakeValueGenerator>();

Snowflake IDs embed a timestamp, making them sortable and unique across nodes without a central counter.

License

MIT

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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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 (1)

Showing the top 1 NuGet packages that depend on Ozcorps.Generic:

Package Downloads
Ozcorps.Localization

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
9.0.0 88 4/3/2026
8.3.0 249 2/4/2026
8.2.0 4,118 8/27/2025
8.1.0 881 6/27/2025
8.0.0 2,921 12/3/2024
2.3.0 82 3/25/2026
2.2.1 4,186 5/21/2024
2.2.0 154 5/21/2024
2.1.0 470 3/27/2024
2.0.0 628 7/6/2023
1.0.0 298 4/6/2023