C# 如何在Breeze中查询字符串列表中的匹配项?

C# 如何在Breeze中查询字符串列表中的匹配项?,c#,javascript,linq,entity-framework,breeze,C#,Javascript,Linq,Entity Framework,Breeze,我在一个WebAPI2,EF6项目中进行了此操作 [HttpGet] public IQueryable<ProductListItem> ProductListItems() { // Db.Products is a DbSet<Product> return Db.Products.ProductListItemProjection(); } 下面是ProductListItemProjection扩展方法: public static IQuer

我在一个WebAPI2,EF6项目中进行了此操作

[HttpGet]
public IQueryable<ProductListItem> ProductListItems()
{
    // Db.Products is a DbSet<Product>
    return Db.Products.ProductListItemProjection();
}
下面是
ProductListItemProjection
扩展方法:

public static IQueryable<ProductListItem> ProductListItemProjection(this IQueryable<Product> products)
{
    // Product.Tags is a list of ProductTags.  A ProductTag has a TagType, which in the database is an int,
    // but is backed by an enum (ProductTagTypes) in the .NET model.  The purpose of this expression is to convert
    // the Product.Tags list to a list of strings - display names depending on the TagType of the ProductTag.
    Expression<Func<Product, IEnumerable<string>>> tagNames =
        (Product p) => p.Tags
            .Select(t =>
                t.TagType == ProductTagTypes.Expensive ? "Expensive" :
                t.TagType == ProductTagTypes.Red ? "Red" :
                t.TagType == ProductTagTypes.Liquid ? "Liquid" : "");

    return products
        .AsExpandable() // From LINQKit...
        .Select(p =>
            new ProductListItem
            {
                // Set various properties inherited from Product
                TagNames = tagNames.Invoke(p) // Using LINQKit...
            });
}
但是我在breeze库中得到一个JS错误(在查询构造期间,在执行之前):

I可以构建一个LINQ到实体查询,该查询按预期工作:

// Returns ProductListItems that have a tag containing the string "Expen" (i.e., "Expensive")
Db.Users.Query().ProductListItemProjection()
    .Where(u => u.TagNames.Any(r => r.Contains("Expen"))); 
但我怎样才能在微风中做到这一点呢?或者这是不受支持的?它将在ODataV3中得到支持,但可能Breeze还不支持它

更新

我可能有一个更普遍的问题。我尝试将
ProductListItem.TagNames
更改为具有
Name
属性的对象列表,而不仅仅是字符串列表。然后我试着:

var query = breeze.EntityQuery.from("ProductListItems")
    .where("tagNames", "any", "name", "contains", "Expen");
这将通过查询创建,但在向服务器发出任何请求之前,它在
executeQuery
中失败:

TypeError {query: j, stack: (...), message: "Cannot read property 'isAnonymous' of undefined"}

考虑使用参数< >参数>()/代码>将参数传递给服务器,并在那里执行高级LINQ查询。另一种方法是在客户端迭代并使用indexOf,这取决于您的数据大小,可能会占用机器的大量资源。@PWKad,我确实考虑过这一点。。。不过,还有其他列正在被过滤(所有列都需要与此列一起被OR'ed),因此我需要获得OData选项(包括所有其他筛选器或'ed一起),将它们传递到一个查询,然后执行另一个只过滤标记的查询,并合并两个查询的结果。把分页和排序放进去(我也在做),这太疯狂了。
// Returns ProductListItems that have a tag containing the string "Expen" (i.e., "Expensive")
Db.Users.Query().ProductListItemProjection()
    .Where(u => u.TagNames.Any(r => r.Contains("Expen"))); 
var query = breeze.EntityQuery.from("ProductListItems")
    .where("tagNames", "any", "name", "contains", "Expen");
TypeError {query: j, stack: (...), message: "Cannot read property 'isAnonymous' of undefined"}