{"id":27298492,"url":"https://github.com/fluentcms/fluentcms.repositories","last_synced_at":"2025-08-19T23:08:43.978Z","repository":{"id":285450460,"uuid":"958181934","full_name":"fluentcms/FluentCMS.Repositories","owner":"fluentcms","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-31T19:51:13.000Z","size":33,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-19T05:50:38.466Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fluentcms.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2025-03-31T19:22:14.000Z","updated_at":"2025-03-31T19:51:16.000Z","dependencies_parsed_at":"2025-03-31T20:43:32.220Z","dependency_job_id":null,"html_url":"https://github.com/fluentcms/FluentCMS.Repositories","commit_stats":null,"previous_names":["fluentcms/fluentcms.repositories"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fluentcms/FluentCMS.Repositories","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluentcms%2FFluentCMS.Repositories","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluentcms%2FFluentCMS.Repositories/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluentcms%2FFluentCMS.Repositories/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluentcms%2FFluentCMS.Repositories/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fluentcms","download_url":"https://codeload.github.com/fluentcms/FluentCMS.Repositories/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluentcms%2FFluentCMS.Repositories/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271236280,"owners_count":24723978,"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","status":"online","status_checked_at":"2025-08-19T02:00:09.176Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-04-12T00:27:24.571Z","updated_at":"2025-08-19T23:08:43.953Z","avatar_url":"https://github.com/fluentcms.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FluentCMS.Repositories\n\nA flexible generic repository pattern implementation supporting multiple database types.\n\n## Overview\n\nFluentCMS.Repositories provides a standardized way to implement data access with support for multiple database providers:\n\n- MongoDB\n- SQL Server\n- SQLite\n\nThe library offers a consistent API surface while enabling database-specific optimizations behind the scenes.\n\n## Features\n\n- Generic repository interfaces for any entity type with a GUID identifier\n- Consistent CRUD operations across all database implementations\n- Flexible querying with filtering, sorting, and pagination\n- Support for MongoDB, SQL Server, and SQLite\n- Dependency injection support for easy integration\n\n## Getting Started\n\n### Prerequisites\n\n- .NET 8.0 or later\n- Connection to your preferred database (MongoDB, SQL Server, or SQLite)\n\n### Installation\n\nInstall the NuGet packages for your preferred database provider:\n\n```shell\n# For MongoDB\ndotnet add package FluentCMS.Repositories.MongoDb\n\n# For SQL Server\ndotnet add package FluentCMS.Repositories.SqlServer\n\n# For SQLite\ndotnet add package FluentCMS.Repositories.Sqlite\n```\n\n### Basic Usage\n\n1. Create an entity class that implements `IBaseEntity`:\n\n```csharp\nusing FluentCMS.Repositories.Abstractions.Entities;\n\npublic class Product : IBaseEntity\n{\n    public Guid Id { get; set; }\n    public string Name { get; set; } = string.Empty;\n    public decimal Price { get; set; }\n    public string Description { get; set; } = string.Empty;\n}\n```\n\n2. Configure the repositories in your service registration:\n\n```csharp\n// MongoDB setup\nservices.AddMongoDbRepositories(options =\u003e\n{\n    options.ConnectionString = \"mongodb://localhost:27017\";\n    options.DatabaseName = \"YourDatabaseName\";\n});\n\n// SQL Server setup\nservices.AddSqlServerRepositories(options =\u003e\n{\n    options.ConnectionString = \"Server=(localdb)\\\\mssqllocaldb;Database=YourDatabase;Trusted_Connection=True;\";\n});\n\n// SQLite setup\nservices.AddSqliteRepositories(options =\u003e\n{\n    options.ConnectionString = \"Data Source=YourDatabase.db\";\n});\n```\n\n3. Inject and use the repository in your services:\n\n```csharp\npublic class ProductService\n{\n    private readonly IBaseEntityRepository\u003cProduct\u003e _productRepository;\n\n    public ProductService(IBaseEntityRepository\u003cProduct\u003e productRepository)\n    {\n        _productRepository = productRepository;\n    }\n\n    public async Task\u003cProduct?\u003e GetProductById(Guid id)\n    {\n        return await _productRepository.GetById(id);\n    }\n\n    public async Task\u003cIEnumerable\u003cProduct\u003e\u003e GetExpensiveProducts(decimal priceThreshold)\n    {\n        return await _productRepository.Query(p =\u003e p.Price \u003e priceThreshold);\n    }\n\n    public async Task AddProduct(Product product)\n    {\n        await _productRepository.Add(product);\n    }\n\n    public async Task UpdateProduct(Product product)\n    {\n        await _productRepository.Update(product);\n    }\n\n    public async Task DeleteProduct(Guid id)\n    {\n        await _productRepository.Delete(id);\n    }\n}\n```\n\n## Advanced Querying\n\n### Filtering\n\n```csharp\n// Simple filter\nvar products = await _repository.Query(p =\u003e p.Price \u003e 100);\n\n// Complex filter\nvar products = await _repository.Query(\n    p =\u003e p.Price \u003e 100 \u0026\u0026 p.Name.Contains(\"smartphone\") \u0026\u0026 p.IsAvailable\n);\n```\n\n### Sorting\n\n```csharp\n// Create sort options\nvar sortOptions = new SortOptions\u003cProduct\u003e();\nsortOptions.Add(p =\u003e p.Price, SortDirection.Descending);\nsortOptions.Add(p =\u003e p.Name);  // Ascending is default\n\n// Apply sorting\nvar products = await _repository.Query(\n    filter: null,\n    sortOptions: sortOptions\n);\n```\n\n### Pagination\n\n```csharp\n// Skip 20 items and take 10\nvar productsPage = await _repository.Query(\n    filter: null,\n    sortOptions: null,\n    skip: 20,\n    take: 10\n);\n\n// Get total count for pagination\nvar totalCount = await _repository.Count();\n```\n\n### Combined Querying\n\n```csharp\n// Filter, sort, and paginate\nvar queryOptions = new QueryOptions\u003cProduct\u003e\n{\n    Filter = p =\u003e p.Category == \"Electronics\",\n    Sort = new SortOptions\u003cProduct\u003e(),\n    Skip = 10,\n    Take = 5\n};\n\nqueryOptions.Sort.Add(p =\u003e p.Price, SortDirection.Descending);\n\nvar products = await _repository.Query(queryOptions);\n```\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffluentcms%2Ffluentcms.repositories","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffluentcms%2Ffluentcms.repositories","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffluentcms%2Ffluentcms.repositories/lists"}