Skip to content

Add named query filter support for .NET 10+#306

Merged
marcominerva merged 4 commits intomasterfrom
develop
Mar 12, 2026
Merged

Add named query filter support for .NET 10+#306
marcominerva merged 4 commits intomasterfrom
develop

Conversation

@marcominerva
Copy link
Copy Markdown
Owner

This pull request introduces significant enhancements to the TinyHelpers.EntityFrameworkCore library, focusing on expanding query filter capabilities and adding comprehensive test coverage. The most important changes are grouped below by theme.

Query Filter Enhancements

  • Added support for applying query filters based on base classes, interfaces, and property names, allowing filters to be applied more flexibly across entity types in ModelBuilderExtensions.
  • Introduced support for named query filters (for .NET 10+), enabling multiple filters per entity type and selective disabling of filters at query time.
  • Improved documentation in README.md to demonstrate usage with interfaces and named query filters, including practical code examples.

Testing Improvements

  • Added a new test project TinyHelpers.EntityFrameworkCore.Tests with extensive unit tests covering all query filter scenarios, including base class, interface, property name, and named filters. [1] [2]
  • Registered the new test project in the solution file TinyHelpers.slnx for better visibility and integration.
  • Added global using for Xunit in the test project to simplify test code.

Closes #288

Copilot AI and others added 4 commits March 11, 2026 20:00
…atibility

- Add ApplyQueryFilter overloads with filterName parameter (NET10_0_OR_GREATER)
- Add XML documentation to all ModelBuilderExtensions methods
- Create TinyHelpers.EntityFrameworkCore.Tests project with 12 unit tests
- Verify ApplyQueryFilter works with both base classes and interfaces
- Update README with interface usage and named query filter documentation

Co-authored-by: marcominerva <3522534+marcominerva@users.noreply.github.com>
Refactored entity type filtering to use GetEntityTypes<TEntity> and IsAssignableTo for improved robustness. Updated query filter property access to use EF.Property<T> for better EF Core query translation support. These changes enhance maintainability and align with EF Core best practices.
Copilot AI review requested due to automatic review settings March 12, 2026 08:55
@marcominerva marcominerva merged commit f7a9657 into master Mar 12, 2026
9 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds named query filter support (.NET 10+) to TinyHelpers.EntityFrameworkCore, refactors existing query filter methods to use GetEntityTypes<T>() and EF.Property<T>(), adds XML documentation, and introduces comprehensive test coverage.

Changes:

  • Added ApplyQueryFilter overloads accepting a filterName parameter (behind #if NET10_0_OR_GREATER) to support named query filters that can be selectively disabled at query time.
  • Refactored existing ApplyQueryFilter<TEntity> to reuse GetEntityTypes<TEntity>() and switched property-based filters to use EF.Property<T>() instead of Expression.Property, and IsAssignableTo instead of IsAssignableFrom.
  • Added a new test project with unit tests covering all query filter variants, and updated the README with interface and named filter documentation.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/TinyHelpers.EntityFrameworkCore/Extensions/ModelBuilderExtensions.cs Added named filter overloads, refactored existing methods, added XML docs
tests/TinyHelpers.EntityFrameworkCore.Tests/Extensions/ModelBuilderExtensionsTests.cs New test class with 11 tests covering all filter scenarios
tests/TinyHelpers.EntityFrameworkCore.Tests/TinyHelpers.EntityFrameworkCore.Tests.csproj New test project targeting net10.0
tests/TinyHelpers.EntityFrameworkCore.Tests/Usings.cs Global using for Xunit
src/TinyHelpers.EntityFrameworkCore/README.md Documentation for interface-based and named query filters
TinyHelpers.slnx Registered new test project in solution

You can also share your feedback on Copilot code review. Take the survey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for named query filters in TinyHelpers.EntityFrameworkCore (available only in .NET 10 and greater)

3 participants