Skip to content

Foundatio RepositoriesProduction-grade repository pattern for .NET

Build robust data access layers with Elasticsearch, caching, messaging, and more

FoundatioFoundatio

Quick Example ​

csharp
// 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"));

Released under the Apache 2.0 License.