OrderSequenceGenerator 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package OrderSequenceGenerator --version 1.0.0
                    
NuGet\Install-Package OrderSequenceGenerator -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="OrderSequenceGenerator" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OrderSequenceGenerator" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="OrderSequenceGenerator" />
                    
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 OrderSequenceGenerator --version 1.0.0
                    
#r "nuget: OrderSequenceGenerator, 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.
#:package OrderSequenceGenerator@1.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=OrderSequenceGenerator&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=OrderSequenceGenerator&version=1.0.0
                    
Install as a Cake Tool

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 sequence to guarantee zero gaps and zero duplicate numbers under extreme concurrency.
  • Automatic Walkthrough Script: Installing this NuGet package automatically places walkthrough.ps1 into 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:

  1. Preview all 17 pattern styles and sample outputs.
  2. Test database connection against PostgreSQL.
  3. Automatically execute the exact table DDL.
  4. 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 0
  • updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
  • CONSTRAINT UQ_<tableName>_scope UNIQUE (<token_columns>)
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

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.2 116 9/9/2026
1.0.1 103 9/9/2026
1.0.0 99 9/9/2026

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.