如何在Breeze JS中筛选子属性集合?

如何在Breeze JS中筛选子属性集合?,breeze,Breeze,我正在尝试根据子实体的集合筛选实体。以下是我的实体(EF POCO): 但这当然行不通。有什么想法吗?有微风是不可能的。我建议您在您的系统中实现一个方法,该方法返回任何订单所在的所有客户。说明中包含“foo”一词 如果您使用的是web API,则类似于: query = entityQuery.from('getCustomerAnyOrderWithFooDescription'); 在您的后端: [HttpGet] public IQueryable<Customer> get

我正在尝试根据子实体的集合筛选实体。以下是我的实体(EF POCO):


但这当然行不通。有什么想法吗?

有微风是不可能的。我建议您在您的系统中实现一个方法,该方法返回任何订单所在的所有客户。说明中包含“foo”一词

如果您使用的是web API,则类似于:

query = entityQuery.from('getCustomerAnyOrderWithFooDescription');
在您的后端:

[HttpGet]
public IQueryable<Customer> getCustomerAnyOrderWithFooDescription()
{
  return _contextProvider.Context.Customers.Where(c.Orders.Any(o => o.Description.Contains('foo')));
}
[HttpGet]
public IQueryable getCustomerOnOrderWithFoodDescription()
{
return _contextProvider.Context.Customers.Where(c.Orders.Any(o=>o.Description.Contains('foo'));
}
此外,您还可以更一般地执行以下操作:

query = entityQuery.from('getCustomerAnyOrderWithDescription').withParameters('foo');

[HttpGet]
public IQueryable<Customer> getCustomerAnyOrderWithDescription([FromBody] String someText)
{
  return _contextProvider.Context.Customers
      .Where(c.Orders.Any(o => o.Description.Contains(someText)));
}
query=entityQuery.from('getCustomerOnOrderWithDescription')。带参数('foo');
[HttpGet]
公共IQueryable GetCustomerOnOrderWithDescription([FromBody]String someText)
{
return\u contextProvider.Context.Customers
其中(c.Orders.Any(o=>o.Description.Contains(someText));
}

从Breeze 1.4.6开始,Breeze现在支持“任意”和“所有”查询运算符

见:

这意味着该查询现在可以组合为:

var query = breeze.EntityQuery.from("Customers")
  .where("Orders", "any", "Description", "contains", "Foo");

Breeze现在支持这个场景:关于相关属性的子句每当我尝试这种语法时,我都会得到以下错误:“TypeError:a未定义”是的,我发现它可以与OData后端一起正常工作。这应该是现在可以接受的答案,因为当前的答案已经过时了。
query = entityQuery.from('getCustomerAnyOrderWithDescription').withParameters('foo');

[HttpGet]
public IQueryable<Customer> getCustomerAnyOrderWithDescription([FromBody] String someText)
{
  return _contextProvider.Context.Customers
      .Where(c.Orders.Any(o => o.Description.Contains(someText)));
}
var query = breeze.EntityQuery.from("Customers")
  .where("Orders", "any", "Description", "contains", "Foo");