Nested query/Navigation Property collection

那年仲夏 提交于 2019-12-08 05:59:21

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!