{"id":28825775,"url":"https://github.com/foundatiofx/foundatio.repositories","last_synced_at":"2026-02-14T05:16:48.896Z","repository":{"id":37821828,"uuid":"50538492","full_name":"FoundatioFx/Foundatio.Repositories","owner":"FoundatioFx","description":"Generic repositories","archived":false,"fork":false,"pushed_at":"2025-06-18T19:54:14.000Z","size":3407,"stargazers_count":81,"open_issues_count":8,"forks_count":26,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-06-18T20:39:38.932Z","etag":null,"topics":["elasticsearch","foundatio","genericrepository","indexing","repository","snapshots"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FoundatioFx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"exceptionless"}},"created_at":"2016-01-27T21:18:49.000Z","updated_at":"2025-06-18T19:50:17.000Z","dependencies_parsed_at":"2023-02-03T13:15:21.762Z","dependency_job_id":"cd572aa1-33f7-4785-b4d3-4153bc937795","html_url":"https://github.com/FoundatioFx/Foundatio.Repositories","commit_stats":{"total_commits":968,"total_committers":13,"mean_commits":74.46153846153847,"dds":0.5299586776859504,"last_synced_commit":"56dec27e5d58050e98bcdf9b84ad12d9a1bf7c74"},"previous_names":[],"tags_count":69,"template":false,"template_full_name":null,"purl":"pkg:github/FoundatioFx/Foundatio.Repositories","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FoundatioFx%2FFoundatio.Repositories","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FoundatioFx%2FFoundatio.Repositories/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FoundatioFx%2FFoundatio.Repositories/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FoundatioFx%2FFoundatio.Repositories/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FoundatioFx","download_url":"https://codeload.github.com/FoundatioFx/Foundatio.Repositories/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FoundatioFx%2FFoundatio.Repositories/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260674814,"owners_count":23045063,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elasticsearch","foundatio","genericrepository","indexing","repository","snapshots"],"created_at":"2025-06-19T02:44:54.550Z","updated_at":"2026-02-14T05:16:48.891Z","avatar_url":"https://github.com/FoundatioFx.png","language":"C#","funding_links":["https://github.com/sponsors/exceptionless"],"categories":[],"sub_categories":[],"readme":"![Foundatio](https://raw.githubusercontent.com/FoundatioFx/Foundatio/master/media/foundatio-dark-bg.svg#gh-dark-mode-only \"Foundatio\")![Foundatio](https://raw.githubusercontent.com/FoundatioFx/Foundatio/master/media/foundatio.svg#gh-light-mode-only \"Foundatio\")\n\n[![Build status](https://github.com/FoundatioFx/Foundatio.Repositories/workflows/Build/badge.svg)](https://github.com/FoundatioFx/Foundatio.Repositories/actions)\n[![NuGet Version](http://img.shields.io/nuget/v/Foundatio.Repositories.svg?style=flat)](https://www.nuget.org/packages/Foundatio.Repositories/)\n[![feedz.io](https://img.shields.io/badge/endpoint.svg?url=https%3A%2F%2Ff.feedz.io%2Ffoundatio%2Ffoundatio%2Fshield%2FFoundatio.Repositories%2Flatest)](https://f.feedz.io/foundatio/foundatio/packages/Foundatio.Repositories/latest/download)\n[![Discord](https://img.shields.io/discord/715744504891703319)](https://discord.gg/6HxgFCx)\n\n# Foundatio.Repositories\n\nA production-grade repository pattern library for .NET with Elasticsearch implementation. Built on [Foundatio](https://github.com/FoundatioFx/Foundatio) building blocks, it provides a clean abstraction over data access with powerful features like caching, messaging, soft deletes, and versioning.\n\n📖 **[Full Documentation](https://repositories.foundatio.dev)**\n\n## Installation\n\n```bash\ndotnet add package Foundatio.Repositories.Elasticsearch\n```\n\n## Quick Start\n\n### 1. Define Your Entity\n\n```csharp\nusing Foundatio.Repositories.Models;\n\npublic class Employee : IIdentity, IHaveDates, ISupportSoftDeletes\n{\n    public string Id { get; set; } = string.Empty;\n    public string Name { get; set; } = string.Empty;\n    public string Email { get; set; } = string.Empty;\n    public int Age { get; set; }\n    public DateTime CreatedUtc { get; set; }\n    public DateTime UpdatedUtc { get; set; }\n    public bool IsDeleted { get; set; }\n}\n```\n\n### 2. Create Index Configuration\n\n```csharp\nusing Foundatio.Repositories.Elasticsearch.Configuration;\n\npublic sealed class EmployeeIndex : VersionedIndex\u003cEmployee\u003e\n{\n    public EmployeeIndex(IElasticConfiguration configuration) \n        : base(configuration, \"employees\", version: 1) { }\n\n    public override TypeMappingDescriptor\u003cEmployee\u003e ConfigureIndexMapping(\n        TypeMappingDescriptor\u003cEmployee\u003e map)\n    {\n        return map\n            .Dynamic(false)\n            .Properties(p =\u003e p\n                .SetupDefaults()\n                .Text(f =\u003e f.Name(e =\u003e e.Name).AddKeywordAndSortFields())\n                .Text(f =\u003e f.Name(e =\u003e e.Email).AddKeywordAndSortFields())\n                .Number(f =\u003e f.Name(e =\u003e e.Age).Type(NumberType.Integer))\n            );\n    }\n}\n```\n\n### 3. Create Repository\n\n```csharp\nusing Foundatio.Repositories;\nusing Foundatio.Repositories.Elasticsearch;\n\npublic interface IEmployeeRepository : ISearchableRepository\u003cEmployee\u003e { }\n\npublic class EmployeeRepository : ElasticRepositoryBase\u003cEmployee\u003e, IEmployeeRepository\n{\n    public EmployeeRepository(MyElasticConfiguration configuration) \n        : base(configuration.Employees) { }\n}\n```\n\n### 4. Use the Repository\n\n```csharp\n// Add\nvar employee = await repository.AddAsync(new Employee \n{ \n    Name = \"John Doe\", \n    Email = \"john@example.com\",\n    Age = 30 \n});\n\n// Query\nvar results = await repository.FindAsync(q =\u003e q\n    .FilterExpression(\"age:\u003e=25\")\n    .SortExpression(\"name\"));\n\n// Update\nemployee.Age = 31;\nawait repository.SaveAsync(employee);\n\n// Soft delete\nemployee.IsDeleted = true;\nawait repository.SaveAsync(employee);\n\n// Hard delete\nawait repository.RemoveAsync(employee);\n```\n\n## Features\n\n### Repository Pattern\n- **`IReadOnlyRepository\u003cT\u003e`** - Read operations (Get, Find, Count, Exists)\n- **`IRepository\u003cT\u003e`** - Write operations (Add, Save, Remove, Patch)\n- **`ISearchableRepository\u003cT\u003e`** - Dynamic querying with filters, sorting, and aggregations\n\n### Patch Operations\n- **JSON Patch** - RFC 6902 compliant patch operations\n- **Partial Patch** - Update specific fields without loading the full document\n- **Script Patch** - Elasticsearch Painless scripts for complex updates\n- **Bulk Patching** - Apply patches to multiple documents via query\n\n### Caching\n- Built-in distributed caching with automatic invalidation\n- Real-time cache consistency via message bus\n- Configurable cache expiration and custom cache keys\n\n### Message Bus\n- Entity change notifications (`EntityChanged` messages)\n- Real-time updates for event-driven architectures\n- Soft delete transition detection (`ChangeType.Removed`)\n\n### Soft Deletes\n- Automatic query filtering based on `IsDeleted`\n- Three query modes: `ActiveOnly`, `DeletedOnly`, `All`\n- Restore capability for soft-deleted documents\n\n### Document Versioning\n- Optimistic concurrency control\n- Automatic version conflict detection\n- Retry patterns for conflict resolution\n\n### Index Management\n- **`Index\u003cT\u003e`** - Basic index configuration\n- **`VersionedIndex\u003cT\u003e`** - Schema versioning with migrations\n- **`DailyIndex\u003cT\u003e`** - Time-series with daily partitioning\n- **`MonthlyIndex\u003cT\u003e`** - Time-series with monthly partitioning\n\n### Event System\n- `DocumentsAdding` / `DocumentsAdded`\n- `DocumentsSaving` / `DocumentsSaved`\n- `DocumentsRemoving` / `DocumentsRemoved`\n- `DocumentsChanging` / `DocumentsChanged`\n- `BeforeQuery` - Query interception\n- `BeforePublishEntityChanged` - Notification interception\n\n### Additional Features\n- Document validation with custom validators\n- Migrations for data schema evolution\n- Jobs for index maintenance, snapshots, and cleanup\n- Custom fields for tenant-specific data\n- Parent-child document relationships\n- Aggregations and analytics\n\n## Documentation\n\nVisit the [full documentation](https://repositories.foundatio.dev) for detailed guides:\n\n- [Getting Started](https://repositories.foundatio.dev/guide/getting-started)\n- [Repository Pattern](https://repositories.foundatio.dev/guide/repository-pattern)\n- [Elasticsearch Setup](https://repositories.foundatio.dev/guide/elasticsearch-setup)\n- [CRUD Operations](https://repositories.foundatio.dev/guide/crud-operations)\n- [Querying](https://repositories.foundatio.dev/guide/querying)\n- [Configuration](https://repositories.foundatio.dev/guide/configuration)\n- [Validation](https://repositories.foundatio.dev/guide/validation)\n- [Caching](https://repositories.foundatio.dev/guide/caching)\n- [Message Bus](https://repositories.foundatio.dev/guide/message-bus)\n- [Patch Operations](https://repositories.foundatio.dev/guide/patch-operations)\n- [Soft Deletes](https://repositories.foundatio.dev/guide/soft-deletes)\n- [Versioning](https://repositories.foundatio.dev/guide/versioning)\n- [Index Management](https://repositories.foundatio.dev/guide/index-management)\n- [Migrations](https://repositories.foundatio.dev/guide/migrations)\n- [Jobs](https://repositories.foundatio.dev/guide/jobs)\n- [Custom Fields](https://repositories.foundatio.dev/guide/custom-fields)\n\n## Sample Application\n\nSee the [sample Blazor application](samples/Foundatio.SampleApp) for a complete working example.\n\n## Related Projects\n\n- [Foundatio](https://github.com/FoundatioFx/Foundatio) - Core building blocks (caching, messaging, queues, jobs)\n- [Foundatio.Parsers](https://github.com/FoundatioFx/Foundatio.Parsers) - Query parsing for dynamic filtering\n\n## Contributing\n\nWe welcome contributions! Please see our [contributing guidelines](CONTRIBUTING.md) for details.\n\n## License\n\nLicensed under the Apache License, Version 2.0. See [LICENSE.txt](LICENSE.txt) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoundatiofx%2Ffoundatio.repositories","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffoundatiofx%2Ffoundatio.repositories","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoundatiofx%2Ffoundatio.repositories/lists"}