{"id":19669882,"url":"https://github.com/craigmccauley/queryr.entityframeworkcore","last_synced_at":"2025-04-29T00:31:13.658Z","repository":{"id":65535603,"uuid":"593361073","full_name":"craigmccauley/QueryR.EntityFrameworkCore","owner":"craigmccauley","description":"Ad-Hoc querying library for EntityFrameworkCore","archived":false,"fork":false,"pushed_at":"2024-06-02T12:58:02.000Z","size":1571,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-08T01:18:33.991Z","etag":null,"topics":["csharp","csharp-library","entity-framework-core","query-builder"],"latest_commit_sha":null,"homepage":"https://www.nuget.org/packages/QueryR.EntityFrameworkCore","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/craigmccauley.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}},"created_at":"2023-01-25T20:29:38.000Z","updated_at":"2024-06-02T12:50:55.000Z","dependencies_parsed_at":"2023-02-15T13:01:40.136Z","dependency_job_id":null,"html_url":"https://github.com/craigmccauley/QueryR.EntityFrameworkCore","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/craigmccauley%2FQueryR.EntityFrameworkCore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/craigmccauley%2FQueryR.EntityFrameworkCore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/craigmccauley%2FQueryR.EntityFrameworkCore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/craigmccauley%2FQueryR.EntityFrameworkCore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/craigmccauley","download_url":"https://codeload.github.com/craigmccauley/QueryR.EntityFrameworkCore/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224142857,"owners_count":17262885,"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":["csharp","csharp-library","entity-framework-core","query-builder"],"created_at":"2024-11-11T17:02:07.536Z","updated_at":"2024-11-11T17:02:57.532Z","avatar_url":"https://github.com/craigmccauley.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# QueryR.EntityFrameworkCore\n\n![QueryR Logo](./assets/logo.png)\n\n[![.NET](https://github.com/craigmccauley/QueryR.EntityFrameworkCore/actions/workflows/dotnet.yml/badge.svg)](https://github.com/craigmccauley/QueryR.EntityFrameworkCore/actions/workflows/dotnet.yml)\n\nQueryR.EntityFrameworkCore adds a few important items into [QueryR](https://github.com/craigmccauley/QueryR) for use with EntityFrameworkCore.\n\n## Includes\n\nQueryR.EntityFrameworkCore introduces a new `EfQuery` object that should be used for querying instead of the QueryR `Query` object.\n\nThe `EfQuery` object has an `Includes` member where the navigation property path can be set to include related entities with the query. It is important to use this setting for specifying Include statements as the values control the maximum search depth for the SparseFields.\n\n## Async QueryResult Extensions\n\nQueryR.EntityFrameworkCore would not be complete without new QueryResult extension methods to call the `CountAsync` and `ToListAsync` extension methods provided by EntityFrameworkCore.\n\n## Web Api Example\n\n```CSharp\npublic class GetAll(IGetAllKerbalsService getAllKerbalsService) : ControllerBase\n{\n    [HttpGet(Routes.Api.Kerbals.Url)]\n    public async Task\u003cIActionResult\u003e Action(\n        [FromQuery(Name = \"\")] QueryParameters parameters) =\u003e\n            Ok(await getAllKerbalsService.GetAllAsync(parameters));\n\n    public class ListWithTotalCount\u003cT\u003e\n    {\n        public int TotalCount { get; set; }\n        public List\u003cT\u003e Items { get; set; } = new();\n    }\n    public interface IGetAllKerbalsService\n    {\n        Task\u003cListWithTotalCount\u003cKerbal\u003e\u003e GetAllAsync(QueryParameters parameters, CancellationToken cancellationToken = default);\n    }\n    public class GetAllKerbalsService(\n        IQueryParametersMapper queryParametersMapper,\n        KerbalDbContext kerbalDbContext\n        ) : IGetAllKerbalsService\n    {\n        public readonly IQueryParametersMapper queryParametersMapper = queryParametersMapper;\n        public readonly KerbalDbContext kerbalDbContext = kerbalDbContext;\n\n        public async Task\u003cListWithTotalCount\u003cKerbal\u003e\u003e GetAllAsync(QueryParameters parameters, CancellationToken cancellationToken = default)\n        {\n            kerbalDbContext.Database.EnsureCreated();\n\n            var query = queryParametersMapper.ToQuery(parameters);\n\n            var (totalCount, kerbals) = await kerbalDbContext.Set\u003cKerbal\u003e().Query(query)\n                .GetCountAndListAsync(cancellationToken);\n\n            //Normally you would use a DTO mapper here to prevent cyclic dependencies.\n            //The ExampleRequests.http file has a request that uses sparse fields to avoid this for the purposes of the demo.\n            return new ListWithTotalCount\u003cKerbal\u003e\n            {\n                TotalCount = totalCount,\n                Items = kerbals\n            };\n        }\n    }\n}\n\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcraigmccauley%2Fqueryr.entityframeworkcore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcraigmccauley%2Fqueryr.entityframeworkcore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcraigmccauley%2Fqueryr.entityframeworkcore/lists"}