问题
Assume the following models: (example taken from Breeze DocCode)
public class Customer {
public Guid CustomerID { get; internal set; }
public ICollection<Order> Orders { get; set; }
}
public class SomeDetail{
public string name{ get; set; }
}
public class Order {
public int OrderID {get; set;}
public Guid? CustomerID {get; set;}
public SomeDetail detail {get; set;}
}
Nested queries against single Navigation Properties are clear to me. How could this be done if the Navigation Property is a collection? Something like this:
var query = EntityQuery.from("Customers")
.where("Orders.detail.name", "==", someName);
As "Text": Select all Customers where the name of the detail of any order this customer has equals someCondition?
I am running into errors here because
.where("Orders.detail.name, "=", someCondition)
is not possible due to the collection. Is there a short way to check for this conditions without building up a number off collections and filtering per hand?
Any help much appreciated here.
回答1:
As of Breeze 1.4.6, we have added support for two new query operators: "any" and "all"
This means that your query can now look something like this.
var query = EntityQuery.from("Customers")
.where("Orders", "any", "detail.name", "==", someName);
See: http://www.breezejs.com/documentation/query-examples
来源:https://stackoverflow.com/questions/13646217/nested-query-navigation-property-collection