NetQueryBuilder.EntityFramework 1.0.0

dotnet add package NetQueryBuilder.EntityFramework --version 1.0.0
                    
NuGet\Install-Package NetQueryBuilder.EntityFramework -Version 1.0.0
                    
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="NetQueryBuilder.EntityFramework" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NetQueryBuilder.EntityFramework" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="NetQueryBuilder.EntityFramework" />
                    
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 NetQueryBuilder.EntityFramework --version 1.0.0
                    
#r "nuget: NetQueryBuilder.EntityFramework, 1.0.0"
                    
#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.
#:package NetQueryBuilder.EntityFramework@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=NetQueryBuilder.EntityFramework&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=NetQueryBuilder.EntityFramework&version=1.0.0
                    
Install as a Cake Tool

NetQueryBuilder.EntityFramework

NetQueryBuilder.EntityFramework is an extension package that integrates NetQueryBuilder with Entity Framework Core, providing a powerful solution for building dynamic queries in your EF Core applications.

License

Important: NetQueryBuilder.EntityFramework is open-source under the MIT license for personal, educational, and non-commercial use. For commercial use, a valid commercial license must be purchased from https://huline.gumroad.com/l/netquerybuilder.

Description

This package extends the core NetQueryBuilder library to work seamlessly with Entity Framework Core. It allows you to dynamically build and execute complex queries against your EF Core DbContext without writing raw SQL or complex LINQ expressions manually.

For detailed information about the core functionality and customization options, please refer to the NetQueryBuilder Core documentation.

Installation

dotnet add package NetQueryBuilder
dotnet add package NetQueryBuilder.EntityFramework

Setup & Configuration

Basic Setup

Register the NetQueryBuilder services in your application's service collection:

// In your Startup.cs or Program.cs
services.AddDbContext<YourDbContext>(options => 
{
    options.UseSqlServer(connectionString);
});

// Register the EF implementation of IQueryConfigurator
services.AddScoped<IQueryConfigurator, EfQueryConfigurator<YourDbContext>>();

Usage Examples

Basic Query

public class ProductService
{
    private readonly IQueryConfigurator _queryConfigurator;
    
    public ProductService(IQueryConfigurator queryConfigurator)
    {
        _queryConfigurator = queryConfigurator;
    }
    
    public async Task<IEnumerable<Product>> GetAllProductsAsync()
    {
        var query = _queryConfigurator.BuildFor<Product>();
        return (await query.Execute(50)).Cast<Product>();
    }
}

Filtering with Conditions

public async Task<IEnumerable<Product>> GetProductsByCategory(string category)
{
    var query = _queryConfigurator.BuildFor<Product>();
    
    // Create a condition using the Equals operator
    query.Condition.CreateNew<EqualsOperator>(
        query.ConditionPropertyPaths.First(p => p.PropertyFullName == "Category"),
        category
    );
    
    return (await query.Execute(50)).Cast<Product>();
}

Complex Filtering with Navigation Properties

public async Task<IEnumerable<Order>> GetOrdersByCustomerCity(string city)
{
    var query = _queryConfigurator.BuildFor<Order>();
    
    // Navigate through relationships
    query.Condition.CreateNew<EqualsOperator>(
        query.ConditionPropertyPaths.First(p => p.PropertyFullName == "Customer.City"),
        city
    );
    
    return (await query.Execute(50)).Cast<Order>();
}

Using Different Operators

public async Task<IEnumerable<Product>> SearchProductsByName(string searchTerm)
{
    var query = _queryConfigurator.BuildFor<Product>();
    var nameProperty = query.ConditionPropertyPaths.First(p => p.PropertyFullName == "Name");
    
    // Use the Like operator for partial matching
    query.Condition.CreateNew(
        nameProperty,
        nameProperty.GetCompatibleOperators().First(o => o.ToString() == "Like"),
        searchTerm
    );
    
    return (await query.Execute(50)).Cast<Product>();
}

public async Task<IEnumerable<Product>> GetProductsInPriceRange(decimal minPrice, decimal maxPrice)
{
    var query = _queryConfigurator.BuildFor<Product>();
    var priceProperty = query.ConditionPropertyPaths.First(p => p.PropertyFullName == "Price");
    
    // Create a compound condition for price range
    query.Condition.CreateNew(
        priceProperty,
        priceProperty.GetCompatibleOperators().First(o => o.ToString() == "GreaterThanOrEqual"),
        minPrice
    );
    
    query.Condition.And();
    
    query.Condition.CreateNew(
        priceProperty,
        priceProperty.GetCompatibleOperators().First(o => o.ToString() == "LessThanOrEqual"),
        maxPrice
    );
    
    return (await query.Execute(50)).Cast<Product>();
}

Performance Considerations

The EntityFramework implementation translates your dynamic queries into EF Core's expression trees, which are then converted to SQL by EF Core. This means:

  1. No client-side evaluation is performed (when possible)
  2. The generated queries respect EF Core's optimization patterns
  3. Navigation properties are handled efficiently with proper JOINs

However, complex dynamic queries may generate more complex SQL than hand-crafted queries. For performance-critical operations with known query patterns, consider using direct LINQ expressions.

Contribution

Contributions are welcome! You can contribute by improving the EF Core integration or by adding support for additional EF Core features.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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 is compatible.  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 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on NetQueryBuilder.EntityFramework:

Package Downloads
NetQueryBuilder.Blazor

Blazor UI components for NetQueryBuilder - Build dynamic queries with MudBlazor-based visual interface including query builder, condition editor, and result tables

NetQueryBuilder.AspNetCore

ASP.NET Core Razor Pages integration for NetQueryBuilder - Tag Helpers, View Components, and base page models for server-side dynamic query building without JavaScript

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 140 1/19/2026