user1265146
user1265146

Reputation: 2065

BreezeJS Query and filter via an entities collections entity

I have the following model:

Products (DbSet<Product>)
ProductHasWidgets (DbSet<ProductHasWidget> many-to-many w/ payload)
Widgets (DbSet<Widget>)

I am getting stuck with querying across and/or from the many-to-many table and have two questions:

How do I write a breeze query to return all Products where:

  1. Widget.IsActive == true
  2. ProductHasWidgets.WidgetId == 1

Upvotes: 0

Views: 238

Answers (2)

Jay Traband
Jay Traband

Reputation: 17052

As of Breeze 1.4.6, Breeze now supports "any" and "all" queries. See: http://www.breezejs.com/documentation/query-examples

Depending on your model, this means that your query would look something like:

var predicate = breeze.Predicate.create("WidgetId", "==" 1)
  .and("Widget.IsActive", "==", true);
var query = EntityQuery.from("Products")
    .where("ProductHasWidgets", "any", predicate);

Upvotes: 0

Ward
Ward

Reputation: 17863

You can't do that from a Breeze client yet because Breeze does not support the any keyword at this time.

You can write a service method to do the query on the server. The client can pass query parameters to that method using the BreezeJS withParameters query verb.

Upvotes: 1

Related Questions