gpt4 book ai didi

linq - WCF 数据服务中的集合存在条件

转载 作者:行者123 更新时间:2023-12-04 15:27:40 24 4
gpt4 key购买 nike

我正在尝试询问我的 OData 服务:

“给我所有没有类别的产品”

与 Products 和 Category 有 m2m 关系。

我试过了:

from p in Products
where p.Categories == null
select p


from p in Products
where !p.Categories.Any()
select p


from p in Products
where p.Categories.Count == 0
select p

但所有这些都给了我不支持的异常(exception)。

我不是在寻找替代品或选项。请不要用其他选项回答。

最佳答案

我在 WCF 数据服务方面的经验是缺少 LINQ to rest 的客户端子集。

我有偏见的选择是将它移动到服务器端,在那里您可以访问 LINQ to entites 的完整实现? (或您用来实现数据服务的任何东西)。

 [WebGet]
public IQueryable<Products> GetProductsWithoutCategories(){
/*start psudo code
from p in Products
where p.Categories.Count == 0
select p


*/

}

关于linq - WCF 数据服务中的集合存在条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3390761/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com