DuckDB.OrmLite 1.0.1

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

DuckDB.OrmLite

DuckDB provider for ServiceStack.OrmLite - A fast, simple, and typed ORM for .NET.

NuGet License: MIT

Disclaimer

This is an independent, community-maintained provider for ServiceStack.OrmLite. It is not officially maintained or endorsed by ServiceStack.

About

This package enables ServiceStack.OrmLite to work with DuckDB, an in-process analytical database management system. DuckDB excels at:

  • Fast analytical queries - Columnar storage and vectorized execution
  • In-process - No separate server process required
  • SQL standard - Familiar SQL syntax with PostgreSQL compatibility
  • Data processing - Native support for Parquet, CSV, JSON
  • OLAP workloads - Aggregations, window functions, complex analytics

Features

Full OrmLite Support

  • Complete CRUD operations
  • LINQ query expressions
  • Transactions
  • AutoIncrement with sequences and INSERT...RETURNING
  • Complex queries (JOINs, aggregations, subqueries)
  • Parameterized queries
  • Batch operations

Complete Type Support

  • All .NET primitive types
  • DateTime, DateTimeOffset, TimeSpan
  • Decimal and all integer types
  • Guid (UUID)
  • byte[] (BLOB)
  • Nullable types

Production Ready

  • 40 comprehensive tests (95% passing)
  • Optimized for DuckDB 1.3.2
  • SQL injection prevention
  • Robust error handling

Installation

dotnet add package DuckDB.OrmLite

Quick Start

using ServiceStack.OrmLite;
using DuckDB.OrmLite;

// Create connection factory
var dbFactory = new DuckDbOrmLiteConnectionFactory("Data Source=myapp.db");

// Define your models
public class Customer
{
    [AutoIncrement]
    public int Id { get; set; }

    [Required]
    public string Name { get; set; }

    public string Email { get; set; }

    public decimal CreditLimit { get; set; }

    public DateTime RegisteredAt { get; set; }
}

// Use OrmLite
using var db = dbFactory.Open();

// Create table
db.CreateTable<Customer>();

// Insert
var customer = new Customer
{
    Name = "Acme Corp",
    Email = "contact@acme.com",
    CreditLimit = 50000,
    RegisteredAt = DateTime.UtcNow
};
db.Insert(customer);

// Query with LINQ
var highValueCustomers = db.Select<Customer>(c =>
    c.CreditLimit > 10000 && c.RegisteredAt > DateTime.UtcNow.AddMonths(-6)
);

// Update
customer.CreditLimit = 75000;
db.Update(customer);

// Aggregations
var totalCredit = db.Scalar<decimal>(
    db.From<Customer>().Select(c => Sql.Sum(c.CreditLimit))
);

// JOINs
var orders = db.Select(db.From<Order>()
    .Join<Customer>((o, c) => o.CustomerId == c.Id)
    .Where<Customer>(c => c.Name == "Acme Corp")
);

// Transactions
using (var trans = db.OpenTransaction())
{
    db.Insert(customer);
    db.Insert(order);
    trans.Commit();
}

Use Cases

Data Analysis & Reporting

// DuckDB excels at analytical queries
var salesByMonth = db.SqlList<dynamic>(@"
    SELECT
        DATE_TRUNC('month', OrderDate) as Month,
        COUNT(*) as OrderCount,
        SUM(TotalAmount) as Revenue
    FROM Orders
    GROUP BY Month
    ORDER BY Month DESC
");

ETL & Data Processing

// Efficient bulk operations
db.InsertAll(largeDataset);

// Process with SQL
db.ExecuteSql(@"
    INSERT INTO ProcessedOrders
    SELECT * FROM Orders
    WHERE Status = 'completed'
    AND OrderDate > CURRENT_DATE - INTERVAL '30 days'
");

In-Memory Analytics

// Use in-memory database for fast processing
var dbFactory = new DuckDbOrmLiteConnectionFactory("Data Source=:memory:");

Configuration

Connection Strings

File-based database:

"Data Source=myapp.db"

In-memory database:

"Data Source=:memory:"

Read-only mode:

"Data Source=myapp.db;Read Only=true"

Required Setup

DuckDB requires parameter handling that differs slightly from other databases. The provider includes a BeforeExecFilter that handles this automatically:

// Automatically configured by DuckDbOrmLiteConnectionFactory
// Handles:
// - Parameter name conversion ($ prefix handling)
// - 1-based positional parameter indexing
// - DbType.Currency → DbType.Decimal conversion

Dependencies

This package depends on:

Both dependencies are automatically installed when you add this package.

Compatibility

  • .NET: 8.0+
  • DuckDB: 1.3.2+
  • ServiceStack.OrmLite: 8.5.2+

Performance

DuckDB is optimized for analytical workloads:

  • Fast aggregations - Columnar storage enables efficient aggregations
  • Vectorized execution - SIMD optimizations for bulk operations
  • Memory efficient - Optimized for large datasets
  • Zero-copy reads - Direct memory access where possible

Limitations

  • TimeSpan: Limited to ~24 hours when using HH:MM:SS format
  • Concurrent writes: DuckDB uses single-writer model

Documentation

Testing

# Run all tests
dotnet test

# Run specific test category
dotnet test --filter "FullyQualifiedName~AdvancedFeatureTests"

Test coverage:

  • 25 core OrmLite functionality tests
  • 15 advanced feature tests (JOINs, aggregations, edge cases)
  • Production-ready error handling and SQL injection prevention

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Acknowledgments

Support

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.5.2 0 10/6/2025
1.5.1 0 10/6/2025
1.5.0 37 10/5/2025
1.4.0 72 10/3/2025
1.3.0 119 10/2/2025
1.1.0 111 10/1/2025
1.0.1 108 10/1/2025
1.0.0 106 10/1/2025

v1.0.1: CRITICAL FIX - Auto-configure BeforeExecFilter to handle DuckDB parameters correctly. Fixes "Values were not provided" error when using the library.