Adding support for Projections #247
Replies: 2 comments 3 replies
-
Hi @davidjamesb, I've been thinking about this feature for a long time, but in most projects, it's not needed directly within Gridify. Currently, you can achieve the same behavior by combining Gridify with other libraries like AutoMapper or Mapster. You can find an example here. That said, I might consider adding a projection feature in the next major version of Gridify. The challenge is that projection aligns more with GraphQL-style queries rather than structured queries with a known return type. Implementing it would require significant breaking changes, which can only be introduced in a major release. Let me know if you have any thoughts or alternative approaches! |
Beta Was this translation helpful? Give feedback.
-
Hey @alirezanet. I had a quick play with the codebase to see how to implement projections natively, without requiring any additional mapping libraries. The main motivation is to be able to accept a 'select' query string parameter from an incoming REST API call to prevent loading all fields from the underlying database query. It's quick and dirty and mainly as an exercise for myself but I've created a branch in my fork here: I've added a few unit tests under the |
Beta Was this translation helpful? Give feedback.
-
Hi. Thanks for your work on this great library.
Are there any plans to support Projections alongside Filtering and Ordering?
This feature would be similar to the
$select
query string parameter from ODATA - where a subset of fields are returned and would most likely involve transforming the selected fields into an expression that can be passed to theSelect(x=>)
on theIQueryable
being Gridify'd.I have implemented something similar in the past for transforming the fields selected within a GraphQL query into expressions that can work with LINQ.
I haven't had time to inspect the codebase and draft a PR but just wondering if there were any thoughts around the viability of bringing this functionality to this library?
Beta Was this translation helpful? Give feedback.
All reactions