嵌套查询/导航属性集合 [英] Nested query/Navigation Property collection
问题描述
假设以下模型:(示例来自Breeze DocCode)
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;}
}
针对单个导航属性的嵌套查询对我来说很清楚。如果Navigation属性是一个集合,该怎么办?像这样的东西:
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?
任何帮助都值得赞赏
推荐答案
从Breeze 1.4.6开始,我们添加了对两个新查询运算符的支持: any和 all
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);
请参阅: http:/ /www.breezejs.com/documentation/query-examples
这篇关于嵌套查询/导航属性集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!