{"id":15681500,"url":"https://github.com/stefh/graphql.entityframeworkcore.dynamiclinq","last_synced_at":"2025-06-24T22:35:48.475Z","repository":{"id":35158202,"uuid":"201331393","full_name":"StefH/GraphQL.EntityFrameworkCore.DynamicLinq","owner":"StefH","description":"GraphQL extensions for EntityFrameworkCore.DynamicLinq to automatically configure the query arguments and execute the query","archived":false,"fork":false,"pushed_at":"2025-04-28T06:58:39.000Z","size":2664,"stargazers_count":12,"open_issues_count":55,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-20T04:33:43.026Z","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/StefH.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"zenodo":null}},"created_at":"2019-08-08T20:20:14.000Z","updated_at":"2024-08-13T01:47:51.000Z","dependencies_parsed_at":"2023-12-19T07:14:42.690Z","dependency_job_id":"6f2d8ae9-7af4-458b-9511-c680ae632bdb","html_url":"https://github.com/StefH/GraphQL.EntityFrameworkCore.DynamicLinq","commit_stats":{"total_commits":75,"total_committers":3,"mean_commits":25.0,"dds":"0.45333333333333337","last_synced_commit":"b14f22ee527a255dbdec2fe01fb5c23107d422de"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/StefH/GraphQL.EntityFrameworkCore.DynamicLinq","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StefH%2FGraphQL.EntityFrameworkCore.DynamicLinq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StefH%2FGraphQL.EntityFrameworkCore.DynamicLinq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StefH%2FGraphQL.EntityFrameworkCore.DynamicLinq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StefH%2FGraphQL.EntityFrameworkCore.DynamicLinq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StefH","download_url":"https://codeload.github.com/StefH/GraphQL.EntityFrameworkCore.DynamicLinq/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StefH%2FGraphQL.EntityFrameworkCore.DynamicLinq/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261768334,"owners_count":23206988,"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":[],"created_at":"2024-10-03T16:55:41.825Z","updated_at":"2025-06-24T22:35:48.451Z","avatar_url":"https://github.com/StefH.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GraphQL.EntityFrameworkCore.DynamicLinq\n\nAdd EntityFramework Core Dynamic IQueryable support to GraphQL.\n\n## Info\n| | |\n|-|-|\n| \u0026nbsp;\u0026nbsp;**Build Azure** | [![Build Status](https://dev.azure.com/stef/GraphQL.EntityFrameworkCore.DynamicLinq/_apis/build/status/StefH.GraphQL.EntityFrameworkCore.DynamicLinq)](https://dev.azure.com/stef/GraphQL.EntityFrameworkCore.DynamicLinq/_build/latest?definitionId=26) |\n| \u0026nbsp;\u0026nbsp;**Codecov** | [![codecov](https://codecov.io/gh/StefH/GraphQL.EntityFrameworkCore.DynamicLinq/branch/master/graph/badge.svg)](https://codecov.io/gh/StefH/GraphQL.EntityFrameworkCore.DynamicLinq) |\n| \u0026nbsp;\u0026nbsp;**NuGet** | [![NuGet: GraphQL.EntityFrameworkCore.DynamicLinq](https://buildstats.info/nuget/GraphQL.EntityFrameworkCore.DynamicLinq)](https://www.nuget.org/packages/GraphQL.EntityFrameworkCore.DynamicLinq)\n| \u0026nbsp;\u0026nbsp;**MyGet (preview)** | [![MyGet: GraphQL.EntityFrameworkCore.DynamicLinq](https://buildstats.info/myget/graphql_entityframeworkcore_dynamiclinq/GraphQL.EntityFrameworkCore.DynamicLinq)](https://www.myget.org/feed/graphql_entityframeworkcore_dynamiclinq/package/nuget/GraphQL.EntityFrameworkCore.DynamicLinq) |\n\n\n# How To\n\nWith this project you can easily expose all properties from the EF Entities as searchable fields on the GraphQL query.\n\n## Entity Type\n\n``` c#\npublic class Room\n{\n    [Key]\n    public int Id { get; set; }\n    public int Number { get; set; }\n    public string Name { get; set; }\n    public bool AllowedSmoking { get; set; }\n    public RoomStatus Status { get; set; }\n}\n```\n\n## GraphQL Type\n\n``` c#\npublic class RoomType : ObjectGraphType\u003cRoom\u003e\n{\n    public RoomType()\n    {\n        Field(x =\u003e x.Id);\n        Field(x =\u003e x.Name);\n        Field(x =\u003e x.Number);\n        Field(x =\u003e x.AllowedSmoking);\n        Field\u003cRoomStatusType\u003e(nameof(RoomModel.Status));\n    }\n}\n```\n\n# Execute the Query\n\n#### Filter on `allowedSmoking`\n``` js\nquery {\n  rooms (allowedSmoking: false) {\n    name\n    number\n    allowedSmoking\n    status\n  }\n}\n```\n\n#### OrderBy `name`\nIt's also possible to add support for an **OrderBy** field, just add the `.SupportOrderBy();` in the code.\n\n``` js\nquery {\n  rooms (orderBy: \"name desc\") {\n    name\n    number\n    status\n  }\n}\n```\n\n#### Paging\nIt's also possible to add support for **Paging**, just add the `.SupportPaging();` in the code.\n\n``` js\nquery {\n  roomsWithPaging (page: 1, pageSize: 2) {\n    id\n    name\n    number\n    status\n  }\n}\n```\n\n# How to use\n\n### Add the required dependency injections\n``` diff\npublic void ConfigureServices(IServiceCollection services)\n{\n+    services.Configure\u003cQueryArgumentInfoListBuilderOptions\u003e(Configuration.GetSection(\"QueryArgumentInfoListBuilderOptions\"));\n+    services.AddGraphQLEntityFrameworkCoreDynamicLinq();\n}\n```\n\n### Update your GraphQL Query\n``` c#\npublic class MyHotelQuery : ObjectGraphType\n{\n    public MyHotelQuery(MyHotelRepository myHotelRepository, IQueryArgumentInfoListBuilder builder)\n    {\n1       var roomQueryArgumentList = builder.Build\u003cRoomType\u003e()\n2           .Exclude(\"Id\")\n3           .SupportOrderBy()\n4           .SupportPaging();\n\n        Field\u003cListGraphType\u003cRoomType\u003e\u003e(\"rooms\",\n5           arguments: roomQueryArgumentList.ToQueryArguments(),\n\n            resolve: context =\u003e myHotelRepository.GetRoomsQuery()\n6               .ApplyQueryArguments(roomQueryArgumentList, context)\n                .ToList()\n        );\n    }\n}\n```\n\n1. Use the `IQueryArgumentInfoListBuilder` to build all possible arguments based on the fields from the GraphQL type (e.g. `RoomType`)\n2. Optionally include/exclude some properties which should not be searchable (this can also be a wildcard like `*Id`)\n3. Optionally add support for OrderBy (argument-name will be `OrderBy`)\n4. Optionally add support for Paging (argument-names will be `Page` and `PageSize`)\n5. Call the `.ToQueryArguments()` to create a new `QueryArguments` object.\n6. Call the `ApplyQueryArguments` extension method to apply the search criteria (optionally the OrderBy and Paging)\n\n### Example\nSee example projec: [examples/MyHotel](https://github.com/StefH/GraphQL.EntityFrameworkCore.DynamicLinq/tree/master/examples/MyHotel) for more details.\n\n\n# References\n- [Microsoft.EntityFrameworkCore.DynamicLinq](https://github.com/StefH/System.Linq.Dynamic.Core)\n- [EntityFramework Core IQueryable](https://docs.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.dbset-1.system-linq-iqueryable-provider)\n- [GraphQL](https://github.com/graphql-dotnet/graphql-dotnet)\n- My example project is based on [ebicoglu/AspNetCoreGraphQL-MyHotel](https://github.com/ebicoglu/AspNetCoreGraphQL-MyHotel).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefh%2Fgraphql.entityframeworkcore.dynamiclinq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstefh%2Fgraphql.entityframeworkcore.dynamiclinq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefh%2Fgraphql.entityframeworkcore.dynamiclinq/lists"}