Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you filter on child property collections in Breeze JS?

Tags:

breeze

I'm trying to filter entities based on a collection of child entities. Here are my entities (EF POCO's):

public class Customer
{
    public int Id { get; set; }
    public string Name { get; set; }
    public ICollection<Order> Orders { get; set; }
}

public class Order
{
    public int Id { get; set; }
    public string Description { get; set; }
}

Using Breeze js I want to return all customers where any Order.Description contains the word 'foo'. I imagined the query to look similar to this:

query = entityQuery.from('Customers')
                   .where("Orders.Description", "contains", "foo");

But of course that won't work. Any ideas?

like image 761
mortware Avatar asked Apr 29 '13 12:04

mortware


1 Answers

As of Breeze 1.4.6, Breeze now supports the "any" and "all" query operators.

See: http://www.breezejs.com/documentation/query-examples

This means that this query can now be composed as:

var query = breeze.EntityQuery.from("Customers")
  .where("Orders", "any", "Description", "contains", "Foo");
like image 193
Jay Traband Avatar answered Oct 05 '22 05:10

Jay Traband