GraphQL.EntityFrameworkCore.DynamicLinq 1.0.3

dotnet add package GraphQL.EntityFrameworkCore.DynamicLinq --version 1.0.3
                    
NuGet\Install-Package GraphQL.EntityFrameworkCore.DynamicLinq -Version 1.0.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="GraphQL.EntityFrameworkCore.DynamicLinq" Version="1.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GraphQL.EntityFrameworkCore.DynamicLinq" Version="1.0.3" />
                    
Directory.Packages.props
<PackageReference Include="GraphQL.EntityFrameworkCore.DynamicLinq" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add GraphQL.EntityFrameworkCore.DynamicLinq --version 1.0.3
                    
#r "nuget: GraphQL.EntityFrameworkCore.DynamicLinq, 1.0.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=GraphQL.EntityFrameworkCore.DynamicLinq&version=1.0.3
                    
Install as a Cake Addin
#tool nuget:?package=GraphQL.EntityFrameworkCore.DynamicLinq&version=1.0.3
                    
Install as a Cake Tool

GraphQL.EntityFrameworkCore.DynamicLinq

Add EntityFramework Core Dynamic IQueryable support to GraphQL.

How To

With this project you can easily expose all properties from the EF Entities as searchable fields on the GraphQL query.

Entity Type

public class Room
{
    [Key]
    public int Id { get; set; }
    public int Number { get; set; }
    public string Name { get; set; }
    public bool AllowedSmoking { get; set; }
    public RoomStatus Status { get; set; }
}

GraphQL Type

public class RoomType : ObjectGraphType<Room>
{
    public RoomType()
    {
        Field(x => x.Id);
        Field(x => x.Name);
        Field(x => x.Number);
        Field(x => x.AllowedSmoking);
        Field<RoomStatusType>(nameof(RoomModel.Status));
    }
}

Execute the Query

Filter on allowedSmoking
query {
  rooms (allowedSmoking: false) {
    name
    number
    allowedSmoking
    status
  }
}
OrderBy name

It's also possible to add support for an OrderBy field, just add the .SupportOrderBy(); in the code.

query {
  rooms (orderBy: "name desc") {
    name
    number
    status
  }
}
Paging

It's also possible to add support for Paging, just add the .SupportPaging(); in the code.

query {
  roomsWithPaging (page: 1, pageSize: 2) {
    id
    name
    number
    status
  }
}

How to use

Add the required dependency injections

public void ConfigureServices(IServiceCollection services)
{
+    services.Configure<QueryArgumentInfoListBuilderOptions>(Configuration.GetSection("QueryArgumentInfoListBuilderOptions"));
+    services.AddGraphQLEntityFrameworkCoreDynamicLinq();
}

Update your GraphQL Query

public class MyHotelQuery : ObjectGraphType
{
    public MyHotelQuery(MyHotelRepository myHotelRepository, IQueryArgumentInfoListBuilder builder)
    {
1       var roomQueryArgumentList = builder.Build<RoomType>()
2           .Exclude("Id")
3           .SupportOrderBy()
4           .SupportPaging();

        Field<ListGraphType<RoomType>>("rooms",
5           arguments: roomQueryArgumentList.ToQueryArguments(),

            resolve: context => myHotelRepository.GetRoomsQuery()
6               .ApplyQueryArguments(roomQueryArgumentList, context)
                .ToList()
        );
    }
}
  1. Use the IQueryArgumentInfoListBuilder to build all possible arguments based on the fields from the GraphQL type (e.g. RoomType)
  2. Optionally include/exclude some properties which should not be searchable (this can also be a wildcard like *Id)
  3. Optionally add support for OrderBy (argument-name will be OrderBy)
  4. Optionally add support for Paging (argument-names will be Page and PageSize)
  5. Call the .ToQueryArguments() to create a new QueryArguments object.
  6. Call the ApplyQueryArguments extension method to apply the search criteria (optionally the OrderBy and Paging)

Sponsors

Entity Framework Extensions and Dapper Plus are major sponsors and proud to contribute to the development of GraphQL.EntityFrameworkCore.DynamicLinq.

Entity Framework Extensions

Dapper Plus

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp1.0 was computed.  netcoreapp1.1 was computed.  netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard1.3 is compatible.  netstandard1.4 was computed.  netstandard1.5 was computed.  netstandard1.6 was computed.  netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net451 is compatible.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen30 was computed.  tizen40 was computed.  tizen60 was computed. 
Universal Windows Platform uap was computed.  uap10.0 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.3 70 6/28/2025
1.0.2 2,198 1/17/2020
1.0.1 1,262 10/12/2019
1.0.0 1,286 9/7/2019
0.0.2 1,151 8/19/2019
0.0.1 1,288 8/11/2019

See CHANGELOG.md