Breeze / breeze.server.net

Breeze support for .NET servers
MIT License
76 stars 62 forks source link

FEATURE REQUEST: Provide advanced OrderBy of compound Predicate #184

Open EchoFoxxtrot opened 1 year ago

EchoFoxxtrot commented 1 year ago

I have a TableA that has a one to many relationship with TableB, which is a 1:1 join table with TableC and I am able to successfully create filter queries using a Predicate in breeze-client like the following:

(value: any) => {
   return new Predicate('navOfTableB', 'any', 'fieldTableC.targetField', FilterQueryOp. Equals, value);
}

Since I'm creating filter critera for columns in a JavaScript grid like AG-Grid, it would be really, really nice to be able to have some mechanism by which I could specify an OrderBy for a field off of an Any/Some relationship. The best I can find in the documentation is filtering on a 1:1 child table's field like

orderBy: 'fieldTableC.targetField'

which is one level to removed from what I need since I'm reading from a join table to a collection of objects. What I need is the ability to order results for TableA from the any/some relationship of TableB and its child table's field TableC.TargetField like:

orderBy: 'navOfTableB.fieldTableC.targetField'  

Breeze-client allows a server call is made using the latter statement that tries to read the field from the IEnumerable and, of course, that attempt fails because it's trying to read the field on the IEnumerable collection and not from the objects themselves.

In SQL Server land, you would simply have table aliases A, B, and C and you could just

ORDER BY C.TargetField, 
A.SomeOtherField 

but is it possible to create such a sort using the existing orderBy syntax for breeze-client so that it is understood by Breeze Server .NET, or if not, could something be devised that could?

steveschmitt commented 1 year ago

@jtraband Any ideas about this one?