OrderSequenceGenerator 1.0.0
See the version list below for details.
dotnet add package OrderSequenceGenerator --version 1.0.0
NuGet\Install-Package OrderSequenceGenerator -Version 1.0.0
<PackageReference Include="OrderSequenceGenerator" Version="1.0.0" />
<PackageVersion Include="OrderSequenceGenerator" Version="1.0.0" />
<PackageReference Include="OrderSequenceGenerator" />
paket add OrderSequenceGenerator --version 1.0.0
#r "nuget: OrderSequenceGenerator, 1.0.0"
#:package OrderSequenceGenerator@1.0.0
#addin nuget:?package=OrderSequenceGenerator&version=1.0.0
#tool nuget:?package=OrderSequenceGenerator&version=1.0.0
OrderSequenceGenerator
Zero-setup, high-performance, atomic order and application numbering generator for .NET 8 backed by PostgreSQL.
- Zero Manual SQL: Automatically provisions PostgreSQL tables, columns matching pattern tokens, and unique composite constraints on application startup.
- 17 Industry Presets: Pre-configured e-Seba, retail, POS, tax invoice, and custom patterns.
- 100% Concurrency Safe: Uses atomic
INSERT ... ON CONFLICT (...) DO UPDATE ... RETURNING sequenceto guarantee zero gaps and zero duplicate numbers under extreme concurrency. - Automatic Walkthrough Script: Installing this NuGet package automatically places
walkthrough.ps1into the consumer project root for interactive command-line testing and setup!
🚀 Quick Start (Zero Manual Setup)
1. Register in Program.cs
using OrderSequenceGenerator;
using OrderSequenceGenerator.Extensions;
var builder = WebApplication.CreateBuilder(args);
// Zero manual SQL setup! Table & columns matching the pattern are created automatically.
builder.Services.AddOrderSequenceGenerator(options =>
{
options.ConnectionString = builder.Configuration.GetConnectionString("DefaultConnection")!;
// Choose from 17 built-in presets:
options.Pattern = OrderPatterns.ESebaCompact; // "{DISTRICT}{yyyy}{PREFIX}{MM}{dd}{SEQ:4}"
// Or specify any custom pattern:
// options.Pattern = "{BRANCH}-{STORE}-{yyyyMMdd}-{SEQ:5}";
options.TableName = "order_sequence"; // default table
options.AutoMigrate = true; // auto-creates columns matching pattern tokens!
});
2. Generate Sequence in Your Controller or Service
using OrderSequenceGenerator;
[ApiController]
[Route("api/[controller]")]
public class OrdersController : ControllerBase
{
private readonly IOrderSequenceGenerator _generator;
public OrdersController(IOrderSequenceGenerator generator)
{
_generator = generator;
}
[HttpPost]
public async Task<IActionResult> CreateOrder([FromBody] CreateOrderRequest request)
{
// Date tokens (yyyy, MM, dd) are automatically filled from UTC now!
string orderNo = await _generator.NextAsync(new
{
District = request.District, // "MN051"
Prefix = "E"
});
// Returns: "MN0512026E09090001"
return Ok(new { OrderNumber = orderNo });
}
}
🛠️ Interactive Terminal Walkthrough
When you add this package to your project, walkthrough.ps1 is automatically delivered to your project root.
Run:
.\walkthrough.ps1
This interactive assistant allows you to:
- Preview all 17 pattern styles and sample outputs.
- Test database connection against PostgreSQL.
- Automatically execute the exact table DDL.
- Test atomic increments directly in your terminal.
📋 Pattern Presets Reference
| Pattern Name | Template | Sample Output |
|---|---|---|
OrderPatterns.ESebaCompact |
{DISTRICT}{yyyy}{PREFIX}{MM}{dd}{SEQ:4} |
MN0512026E09090001 |
OrderPatterns.ESebaDelimited |
{DISTRICT}-{yyyy}{MM}{dd}-{PREFIX}-{SEQ:4} |
MN051-20260909-E-0001 |
OrderPatterns.DeptCitizenService |
{DEPT}-{DISTRICT}-{yyyy}-{SEQ:4} |
REV-MN051-2026-0001 |
OrderPatterns.StandardRetail |
{PREFIX}-{yyyyMMdd}-{SEQ:4} |
ORD-20260909-0001 |
OrderPatterns.StoreCounterPos |
{PREFIX}-{STORE}-{POS}-{yyMM}-{SEQ:3} |
ORD-NY01-C1-2609-001 |
OrderPatterns.MultiBranchRetail |
{PREFIX}-{BRANCH}-{yyyyMMdd}-{SEQ:4} |
ORD-MUM-20260909-0001 |
OrderPatterns.MonthlyInvoice |
{PREFIX}/{yyyy}/{MM}/{SEQ:4} |
INV/2026/09/0001 |
OrderPatterns.FiscalYearInvoice |
{PREFIX}/{yy}-{next_yy}/{SEQ:6} |
INV/26-27/000001 |
OrderPatterns.PurchaseOrder |
{PREFIX}-{yyyy}-{SEQ:5} |
PO-2026-00012 |
OrderPatterns.ContinuousAccount |
{PREFIX}-{SEQ:6} |
ACC-000042 |
📦 Database Structure
Created automatically by AutoMigrate = true:
id BIGSERIAL PRIMARY KEY- Dynamically generated columns for every custom token in pattern (e.g.
district VARCHAR(50),prefix VARCHAR(50),year INT,month INT,day INT) sequence BIGINT NOT NULL DEFAULT 0updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMPCONSTRAINT UQ_<tableName>_scope UNIQUE (<token_columns>)
| 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. 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. |
-
net8.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.1)
- Microsoft.Extensions.Options (>= 8.0.2)
- Npgsql (>= 8.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Initial release 1.0.0. Complete zero-setup atomic sequence generator for PostgreSQL with 17 built-in patterns (including e-Seba Compact and Delimited), automatic schema migration, and automatic walkthrough.ps1 interactive script setup.