Aquila.Core
1.1.0.6-preview
See the version list below for details.
dotnet add package Aquila.Core --version 1.1.0.6-preview
NuGet\Install-Package Aquila.Core -Version 1.1.0.6-preview
<PackageReference Include="Aquila.Core" Version="1.1.0.6-preview" />
<PackageVersion Include="Aquila.Core" Version="1.1.0.6-preview" />
<PackageReference Include="Aquila.Core" />
paket add Aquila.Core --version 1.1.0.6-preview
#r "nuget: Aquila.Core, 1.1.0.6-preview"
#:package Aquila.Core@1.1.0.6-preview
#addin nuget:?package=Aquila.Core&version=1.1.0.6-preview&prerelease
#tool nuget:?package=Aquila.Core&version=1.1.0.6-preview&prerelease
Aquila Framework
Aquila is a high-performance, Cosmos DB native Document Store and Event Sourcing framework for .NET, inspired by MartenDB. Designed from the ground up for modern cloud-native architectures, Aquila enables seamless document persistence, atomic batch mutations, event stream management, live projections, and multi-tenant isolation over Azure Cosmos DB or in-memory test providers.
Key Features
- 🌌 Cosmos DB Native: Direct connection mode support optimized for Azure Cosmos DB container structure using single-container partitioning (
/pk) and hierarchical partition keys viaPartitionKeyBuilder. - ⚡ 1-RU Point Reads: High-efficiency point reads (
LoadAsync<T>) executing directReadItemAsyncoperations requiring ~1 Request Unit. - 🔌 Decoupled Storage SPI: Independent document (
IDocumentStorageProvider) and event (IEventStorageProvider) storage engines, supported byCosmosStorageProvider(CosmosDocumentStorageProvider&CosmosEventStorageProvider) for cloud persistence andInMemoryStorageProviderfor testing. - 📜 Event Sourcing: First-class stream append operations (
StartStream,Append), expected version concurrency checks, stream fetching (FetchStreamAsync), and aggregate rehydration (AggregateStreamAsync). - 🔁 Event Upcasting & Snapshotting: Transparent schema evolution via
IEventUpcasterchains, plusISnapshotStrategy<TAggregate>-driven aggregate snapshots to avoid full-stream replay on rehydration. - 📊 Projections: Read-model generation via
SingleStreamProjection<TAggregate>andMultiStreamProjection<TDoc,TId>, offeringInline(transaction-scoped),Async(background daemon), andLive(on-the-fly, unpersisted) execution lifecycles. - 🛰️ Async Projection Daemon: A background
IProjectionDaemonwith durable checkpointing,CatchUpAsync(), and zero-downtimeRebuildProjectionAsync()— plus a Cosmos DB Change Feed-aware variant (CosmosProjectionDaemon) viaAddCosmosDaemon(). - ✂️ Partial Document Patching: Fluent
IPatchExpression<T>API (Set,Increment,Append,Remove) for low-payload mutations that skip full read-modify-write round-trips, executed server-side on Cosmos DB via the Patch API. - 🧮 Compiled Queries:
ICompiledQuery<TDoc,TResult>with aCompiledQueryCachethat compiles each query shape's expression tree once and reuses it across parameter values. - 🎛️ Session Tracking Modes: Choose
Lightweight,IdentityMap, orDirtyTrackingper session to control identity-map caching and automatic JSON-snapshot dirty checking. - 🏢 Multi-Tenant Isolation: Tenant scoping enforced natively at session, document envelope, query, and event store levels.
- 🛡️ Built-in Safety & Performance:
- Compiled Expression Trees for zero-reflection event instantiation, property copying, ID selector resolution, upcast envelope creation, and compiled-query execution.
- Automatic document state snapshotting on
Store()to prevent post-store object mutations. - Sync-over-async thread starvation protection (blocking synchronous queries throw
NotSupportedException).
ASP.NET Core Dependency Injection Setup
Register Aquila in your Program.cs or Startup.cs using the fluent AddAquila extension method.
Azure Cosmos DB Provider
using Aquila.Core.Configuration;
using Aquila.Core.Projections;
using Aquila.Cosmos.Extensions;
using Microsoft.Extensions.DependencyInjection;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddAquila(options =>
{
// Configure Cosmos DB storage provider
options.UseCosmos(
connectionString: builder.Configuration.GetConnectionString("CosmosDb")!,
databaseName: "ProductionDB",
containerName: "AquilaDocuments"
);
// Configure document identity and partition key policies
options.Schema.For<UserAccount>()
.Identity(u => u.Id)
.PartitionKey(u => u.Region);
// Register projections
options.Projections.Add<UserProfileProjection>(ProjectionLifecycle.Inline);
});
In-Memory Storage Provider (Testing / Local Dev)
builder.Services.AddAquila(options =>
{
options.UseInMemoryStorage();
options.DefaultTenantId = "dev-tenant";
});
Quickstart Guide
1. Document CRUD Operations
using Aquila.Core.Abstractions;
public class CustomerService
{
private readonly IDocumentStore _store;
public CustomerService(IDocumentStore store)
{
_store = store;
}
public async Task ManageCustomerAsync()
{
// Open a unit-of-work document session
using var session = _store.OpenSession();
var customer = new Customer
{
Id = Guid.NewGuid().ToString(),
Name = "Jane Doe",
Email = "jane@example.com",
Region = "US-East"
};
// Store document (snapshots state immediately)
session.Store(customer);
await session.SaveChangesAsync();
// 1-RU Point Read by Id and Partition Key
var loaded = await session.LoadAsync<Customer>(customer.Id, partitionKey: "US-East");
// Query documents asynchronously
var eastCoastCustomers = await session.QueryAsync<Customer>(
c => c.Data.Region == "US-East"
);
// Soft delete document
await session.SoftDeleteAsync<Customer>(customer.Id, partitionKey: "US-East");
await session.SaveChangesAsync();
}
}
2. Event Sourcing & Aggregate Rehydration
// Define Event Records
public record OrderPlaced(string OrderId, string CustomerId, decimal TotalAmount);
public record ItemAdded(string OrderId, string ItemSku, decimal Price);
public record OrderCompleted(string OrderId, DateTimeOffset CompletedAt);
// Define Aggregate with Apply methods
public class OrderAggregate
{
public string Id { get; set; } = string.Empty;
public string CustomerId { get; set; } = string.Empty;
public decimal Total { get; set; }
public bool IsCompleted { get; set; }
public void Apply(OrderPlaced @event)
{
Id = @event.OrderId;
CustomerId = @event.CustomerId;
Total = @event.TotalAmount;
}
public void Apply(ItemAdded @event)
{
Total += @event.Price;
}
public void Apply(OrderCompleted @event)
{
IsCompleted = true;
}
}
// Start Stream & Rehydrate Aggregate
public async Task ProcessOrderStreamAsync(IDocumentStore store, string orderId)
{
using var session = store.OpenSession();
// Start a new event stream
session.Events.StartStream<OrderAggregate>(orderId,
new OrderPlaced(orderId, "CUST-100", 99.99m),
new ItemAdded(orderId, "SKU-ABC", 25.00m)
);
await session.SaveChangesAsync();
// Append subsequent events with concurrency check (expectedVersion)
session.Events.Append(orderId, expectedVersion: 2, new OrderCompleted(orderId, DateTimeOffset.UtcNow));
await session.SaveChangesAsync();
// Rehydrate state by replaying event stream
var order = await session.Events.AggregateStreamAsync<OrderAggregate>(orderId);
Console.WriteLine($"Order {order?.Id} Total: ${order?.Total}, Completed: {order?.IsCompleted}");
}
3. Projections
// Define SingleStreamProjection for read-model generation
public class OrderSummaryProjection : SingleStreamProjection<OrderAggregate>
{
public OrderSummaryProjection()
{
CreateEvent<OrderPlaced>(e => new OrderAggregate
{
Id = e.OrderId,
CustomerId = e.CustomerId,
Total = e.TotalAmount
});
ProjectEvent<ItemAdded>((e, agg) => agg.Total += e.Price);
ProjectEvent<OrderCompleted>((e, agg) => agg.IsCompleted = true);
}
}
Building & Testing
Prerequisites
Build Solution
dotnet build Aquila.slnx
Run Unit & Integration Tests
dotnet test Aquila.slnx
Documentation
- 📐 Architecture Guide - Detailed sitemap, SPI storage engine specs, sequence diagrams, and security controls.
- 📖 Usage & Features Guide - Deep dive into document mapping, soft deletes, optimistic concurrency, event sourcing, projections (single/multi-stream/live/async), the projection daemon, patching, upcasting, snapshotting, compiled queries, session tracking modes, and multi-tenancy.
License
This project is licensed under the MIT License.
| Product | Versions 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. |
-
net10.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.10)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.10)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.10)
- Newtonsoft.Json (>= 13.0.4)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Aquila.Core:
| Package | Downloads |
|---|---|
|
Aquila.Cosmos
Azure Cosmos DB storage engine, Change Feed projection daemon, and point patching implementation for the Aquila Document Store and Event Sourcing framework. |
|
|
Aquila.Redis
High-performance Redis projection storage provider, document store, and checkpoint persistence for the Aquila Document Store & Event Sourcing Framework. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.1.1.16 | 166 | 9/25/2026 |
| 1.1.0.15 | 155 | 9/2/2026 |
| 1.1.0.12-preview | 155 | 8/21/2026 |
| 1.1.0.11-preview | 127 | 8/19/2026 |
| 1.1.0.10-preview | 113 | 8/18/2026 |
| 1.1.0.9-preview | 112 | 8/17/2026 |
| 1.1.0.8-preview | 115 | 8/16/2026 |
| 1.1.0.7-preview | 115 | 8/16/2026 |
| 1.1.0.6-preview | 116 | 8/15/2026 |
| 1.1.0.5-preview | 114 | 8/14/2026 |
| 1.0.1.4-preview | 118 | 8/13/2026 |
| 1.0.0.3-preview | 118 | 8/12/2026 |