Skip to content

Make properties nullable in filter objects #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

enisn
Copy link
Owner

@enisn enisn commented Feb 25, 2025

Resolves #75

All tests are passed but I'm not sure if it's a breaking-change or not. I'll investigate the progress with preview release

@enisn enisn added enhancement New feature or request autofilterer labels Feb 25, 2025

public override IQueryable<TEntity> ApplyFilterTo<TEntity>(IQueryable<TEntity> query)
{
if (query is IOrderedQueryable<TEntity> ordered)
return this.ApplyFilterTo(ordered);

return base.ApplyFilterTo(query).ToPaged(Page, PerPage);
return base.ApplyFilterTo(query).ToPaged(Page ?? 1, PerPage ?? 10);

Choose a reason for hiding this comment

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

When Page or PrePage is null, consider skipping pagination.

Choose a reason for hiding this comment

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

This should not be modified, it is required to pass in paging parameters here. What's your opinion.

Copy link
Owner Author

Choose a reason for hiding this comment

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

We have ApplyFilterWithoutPagination() method to ignore pagination. It's not client-controlled since skipping pagination may cause big performance problems and a bottleneck in the main application. When required, calling query.ApplyFilterWithoutPagination(filter) method in the code is a good approach. Makes the developer know about no-filtering instead of being managed by the client. But it depends on case, but this one is more common

@enisn enisn requested a review from Copilot June 17, 2025 06:42
Copy link

@Copilot 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 makes the filter properties nullable to allow for better handling of missing filter criteria.

  • Changed string filter properties to be nullable in StringFilter.
  • Modified pagination properties to be nullable in PaginationFilterBase and IPaginationFilter with proper defaulting.
  • Updated ordering properties to be nullable in OrderableBase and IOrderable.

Reviewed Changes

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

Show a summary per file
File Description
src/AutoFilterer/Types/StringFilter.cs Made string properties nullable
src/AutoFilterer/Types/PaginationFilterBase.cs Updated pagination properties to be nullable and added null coalescing for default values
src/AutoFilterer/Types/OrderableBase.cs Changed Sort property to be nullable
src/AutoFilterer/Abstractions/IPaginationFilter.cs Updated pagination interface with nullable ints
src/AutoFilterer/Abstractions/IOrderable.cs Updated ordering interface with nullable string
Comments suppressed due to low confidence (1)

src/AutoFilterer/Types/StringFilter.cs:28

  • Using 'Equals' as a property name can cause confusion with the Object.Equals method. Consider renaming it to a more descriptive name (e.g., 'EqualTo').
public virtual new string? Equals { get; set; }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autofilterer enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make PaginationFilterBase's properties nullable
2 participants