Repository Pattern
Clean abstraction over data access with IRepository, IReadOnlyRepository, and ISearchableRepository interfaces.
Build robust data access layers with Elasticsearch, caching, messaging, and more
Clean abstraction over data access with IRepository, IReadOnlyRepository, and ISearchableRepository interfaces.
Full async CRUD support with Add, Save, Get, Remove operations and lifecycle events.
Flexible document updates with JSON Patch, partial patches, Painless scripts, and bulk patching.
Built-in distributed caching with automatic invalidation and real-time cache consistency.
Real-time entity change notifications via message bus for event-driven architectures.
Dynamic querying with Foundatio.Parsers for filtering, sorting, and aggregations.
Built-in soft delete support with automatic query filtering and restore capabilities.
Optimistic concurrency control with document versioning and conflict detection.
Schema versioning with daily, monthly, and versioned index strategies.
Document migration infrastructure for evolving your data schema over time.
Built-in jobs for index maintenance, snapshots, cleanup, and reindexing.
Dynamic field support for tenant-specific or user-defined fields with type safety.
// Define your entity
public class Employee : IIdentity, IHaveDates, ISupportSoftDeletes
{
public string Id { get; set; }
public string Name { get; set; }
public int Age { get; set; }
public DateTime CreatedUtc { get; set; }
public DateTime UpdatedUtc { get; set; }
public bool IsDeleted { get; set; }
}
// Create a repository
public class EmployeeRepository : ElasticRepositoryBase<Employee>, IEmployeeRepository
{
public EmployeeRepository(EmployeeIndex index) : base(index) { }
}
// Use the repository
var employee = await repository.AddAsync(new Employee { Name = "John", Age = 30 });
var found = await repository.FindAsync(q => q.FilterExpression("age:>=25"));