Print Page | Close Window

More querying questions!

Printed From: IdeaBlade
Category: Breeze
Forum Name: Community Forum
Forum Discription: Build rich JavaScript apps using techniques you already know
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3747
Printed Date: 23-Oct-2019 at 4:45am


Topic: More querying questions!
Posted By: Orizz
Subject: More querying questions!
Date Posted: 29-Oct-2012 at 5:59am
Hi there,

Is the following possible?

I have a Customer object which is queried and includes an expand to get all the orders too. 

.from("Customer").expand("Orders");

I want to be able to only bring back orders which has been completed. 

So select the top level customer expand the orders so I get an Customer object with a List of orders and finally a list of orders which have been completed.

How do I get to the Completed property of the navigation object?

Many thanks!



Replies:
Posted By: Orizz
Date Posted: 29-Oct-2012 at 9:46am
If it is not possible, is there a recommended workaround?

If I select completed orders and expand customers (so the inverse) The json is parsed in such a way that it doesn't really increase the payload too much (using $ref), but obviously if there are no completed orders, the customer can't be returned!

The only way I can see around it is to do 2 calls to the web api, one to get the customer object and one to get the completed orders for that customer, I guess this all relates to sub queries in some way

Anyway a recommended workaround solution would be a great help!

Thanks




Posted By: jtraband
Date Posted: 29-Oct-2012 at 2:18pm
Ok, I think I understand.  Do you mean that the problem is that this query
   from("Orders").where("Completed", "eq", true).expand("Customer");
does not return any "customer" entities when there are no "completed" orders? and presumably you want these customers as well.

If so, then I agree the only current approach is to perform the two queries.
   from("Customers")
followed by
   from("Orders").where("Completed", "eq", true);

The second query will automatically link the "orders" returned with the appropriate customers.

We have discussed, meaning this does not yet work, expressing this with a subquery within a projection query that might look something like this:
  from("Customers").select('this, orders.where("Completed", "eq", true)'
but we do not yet support subqueries in projections.



Posted By: Orizz
Date Posted: 29-Oct-2012 at 2:27pm
That's correct, 

I think the subqueries in projections would be a great addition for Breeze, I've come up a few situations where this would have aided the solution gracefully, I understand it's about prioritising features and producing this functionality in the right way though - so look forward to it!

Many thanks



Print Page | Close Window