© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
18 replies
Anton

❔ ASP.NET Core search

Can someone give me a few pointers at how to implement a generic search system? My initial thought was like here https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-mvc-app/search?view=aspnetcore-7.0 checking every possible filter and then applying them, but a generic system would be better if there are many filters. So like a
ISearchFilter
ISearchFilter
that would update the built database query, a request model with
ISearchFilter[]
ISearchFilter[]
which I'd loop through to apply the filters. The thing is that the ASP.NET Core binding system will have to instantiate the right implementations of
ISearchFilter
ISearchFilter
by the name given in the request body, and then there's the question of how bad would be dynamic queries like this in EF Core?
// an interface kinda like this
public interface ISearchFilter<T>
{
    IQueryable<T> Apply(IQueryable<T> e);
}
// an interface kinda like this
public interface ISearchFilter<T>
{
    IQueryable<T> Apply(IQueryable<T> e);
}

// a request body kinda like this
{
    "Filters": [
        {
            "Type": "FilterType",
            "SomeProperty": 5
        },
        {
            // blah
        }
    ]
}
// a request body kinda like this
{
    "Filters": [
        {
            "Type": "FilterType",
            "SomeProperty": 5
        },
        {
            // blah
        }
    ]
}

Is there some sort of built-in support for things like this, or do I have to roll out my own system?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ ASP.NET to .net Core
C#CC# / help
3y ago
ASP.NET CORE MVC VS ASP.NET CORE WEB API
C#CC# / help
17mo ago
Learning ASP.Net Core
C#CC# / help
8mo ago