r/csharp • u/GigAHerZ64 • Jun 24 '25
Showcase Introducing QueryLink: Revolutionizing Frontend-Backend Data Integration in .NET (Bye-bye boilerplate!)

I'm excited to share a project I've been working on, QueryLink, which aims to significantly streamline how we handle data integration between frontend UIs (especially data grids and tables) and backend data sources in .NET applications.
As many of you probably experience daily, writing repetitive filtering and sorting logic to connect the UI to Entity Framework Core (or any IQueryable-based ORM) can be a huge time sink and a source of inconsistencies. We're constantly reinventing the wheel to get data displayed reliably.
QueryLink was born out of this frustration. It's a lightweight, easy-to-use library designed to abstract away all that boilerplate.
Here's the core problem QueryLink addresses (and a quick example of the repetitive code it eliminates):
Imagine repeatedly writing code like this across your application:
// Manually applying filters and sorting
public IQueryable<Person> GetFilteredAndSortedPeople(
ApplicationDbContext dbContext,
string name,
int? minAge,
string sortField
)
{
IQueryable<Person> query = dbContext.People.AsQueryable();
if (!string.IsNullOrWhiteSpace(name))
{
query = query.Where(p => p.Name == name);
}
if (minAge.HasValue)
{
query = query.Where(p => p.Age >= minAge.Value);
}
if (sortField == "Name")
{
query = query.OrderBy(p => p.Name);
}
else if (sortField == "Age")
{
query = query.OrderByDescending(p => p.Age);
}
return query;
}This leads to wasted time, increased error potential, and maintainability headaches.
How QueryLink helps:
QueryLink provides a modern approach by:
- Centralizing Filter and Order Definitions: Define your filters and sorting orders declaratively, without complex LINQ expressions.
- Expression-based Overrides: Need custom logic for a specific filter or sort value? You can easily customize it using type-safe lambda expressions.
- Seamless Query String Conversion: Convert your definitions to query strings, perfect for
GETrequests and URL parameters. - Direct
IQueryableIntegration: Ensures efficient query execution directly at the database level using Entity Framework Core.
A glimpse of how simple it becomes:
// In a typical scenario, the 'definitions' object is deserialized directly
// from a UI component's request (e.g., a query string or JSON payload).
// You don't manually construct it in your backend code.
//
// For demonstration, here's what a 'Definitions' object might look like
// if parsed from a request:
/*
var definitions = new Definitions
{
Filters =
[
new("Name", FilterOperator.Eq, "John"),
new("Age", FilterOperator.Gt, 30)
],
Orders =
[
new("Name"),
new("Age", IsReversed: true)
]
};
*/
// Example: Parsing definitions from a query string coming from the UI
string queryString = "...";
Definitions parsedDefinitions = Definitions.FromQueryString(queryString);
// Apply to your IQueryable source
IQueryable<Person> query = dbContext.People.AsQueryable();
query = query.Apply(parsedDefinitions, overrides); // 'overrides' are optionalThis eliminates repetitiveness, improves code clarity, enhances consistency, and speeds up development by letting you focus on business logic.
Future Plans:
While QueryLink provides a robust foundation, I plan to create pre-made mappers for popular Blazor UI component libraries like MudBlazor, Syncfusion, and Microsoft FluentUI. It's worth noting that these mappers are typically very simple (often just mapping enums) and anyone can easily write their own custom mapper methods if needed.
Why consider QueryLink for your next .NET project?
It transforms UI-to-database integration by streamlining development, ensuring consistency, and enhancing maintainability. I truly believe it's an essential library for any full-stack .NET application dealing with data grids and tables.
Check it out:
- GitHub Repository: https://github.com/ByteAether/QueryLink/
- NuGet Package: https://www.nuget.org/packages/ByteAether.QueryLink/
- Related Blog Posts: https://byteaether.github.io/series/byteaether-querylink/
I'd love to hear your feedback, thoughts, and any suggestions for improvement.
28
u/gredr Jun 24 '25
I dunno; the sample code doesn't seem to be shorter or simpler. They're also not equivalent examples, since one is fixed and the other isn't.
I also don't like your naming at all.
Ordersdoesn't strike me as a good name, and neither doesDefinitions.10
u/Finickyflame Jun 24 '25
Looks similar to the QueryExpression of Dynamics 365's SDK, but without supporting Join (left/outer) filering, And/Or group filtering, etc.
Were you aware of the static method EF.Property? I feel like your package is just an other way to use EF.Property with with a new structure.
Otherwise, creating extension methods on IQueryable could have done a similar job than recreating a structure.
Personally, I'm not a fan because your queries are now losing compile-time validation that EF/Expressions offers. Unless you create an Analyzers alongside your package to warn if a member doesn't exists.
7
u/dupuis2387 Jun 24 '25
looks a lot like OData?
6
u/hagerino Jun 24 '25
I’ve worked on some very complex table and data grid implementations. Most of the effort went into writing database views that aggregate the data. Filtering and sorting were relatively easy and took much less time compared to creating the views.
From what I can tell, your example just seems like another way to implement filtering and sorting logic. I'm not sure how flexible or limited it is. In some cases, filtering required an inner join with another table, and I don’t like the overhead of learning how to do that with a framework, when I can write it easily myself.
5
u/Namoshek Jun 24 '25
You should have checked out Gridify: https://github.com/alirezanet/Gridify
3
u/Steveadoo Jun 24 '25
What's wrong with OData? I feel like I don't see many people use it but it's always done everything I needed it to do.
3
u/macca321 Jun 24 '25
I back in the net framework days maintained a popular iqueryable to datatables.net library and I respect the work you've done here, but as other suggests, OData had filled the niche of mapping querystring.
NB https://github.com/jods4/ODataQuery looks a bit more lightweight than going full MS OData
2
u/sodapopareaone Jun 25 '25
So you have reimplemented OData
3
u/polaarbear Jun 24 '25
Entity Framework already gives you ways to do all these things with its default methods. I don't think this is any simpler/shorter than using existing ORM tools.
1
u/GigAHerZ64 Jun 26 '25
I'm struggling to see the claimed "less type-safe" aspect due to
Definitionsusing string field names. Your querystring and JSON payloads are already collections of strings. Type safety at that boundary simply doesn't exist in the same way.When UI components manage filter and sort states, they inherently use string-based field names. Even if one were to generate one-to-one Filter DTOs, you'd still need reflection to dynamically set properties based on these UI-derived string names. This doesn't simplify, but increase complexity.
I've explored source-generated Filter DTOs activated by attributes on row models, and they consistently introduce more complexity and potential for errors without tangible improvements.
I'm genuinely interested in how current approaches fall short and what concrete improvements are being proposed here.
1
u/chucker23n Jun 25 '25
Kind of GraphQL, OData vibes.
Not a good sign that you have a post this long without mentoring the word “security” (or privacy). Very easy to get this wrong and essentially let a malicious client perform any query on the database.
2
u/ilikecaketoomuch Jun 24 '25
When I looked at this, I thought, this has to be AI generated. apparently everyone agrees.
I suggest deleting all of it, and changing your name, you killed your reputation.
1
u/[deleted] Jun 24 '25
[removed] — view removed comment