c# – Linq List包含
发布时间:2020-12-15 08:13:36 所属栏目:百科 来源:网络整理
导读:我正在使用ArangoDB,我正在查询名为movies的集合.它的数据结构是类别是字符串列表. public class movies{ [DocumentProperty(Identifier = IdentifierType.Key)] public string Key; public Liststring categories; public string desc; public string img;
我正在使用ArangoDB,我正在查询名为movies的集合.它的数据结构是类别是字符串列表.
public class movies { [DocumentProperty(Identifier = IdentifierType.Key)] public string Key; public List<string> categories; public string desc; public string img; public List<vod_stream> streams; public string title; }; 这是查询语句: var result = db.Query<movies>() .Where(p => p.categories.Contains(id)); id作为参数传递,我需要检索具有与id匹配的类别的所有电影. foreach (movies mov in result) { if (mov.categories.Contains(id) == false) { continue; } // do something here } 奇怪的是当我遍历结果中的项目时,相同的函数会为某些项目返回false.但它只是在Linq声明中不起作用. 有人知道我的查询语句有什么问题吗? 解决方法
要在ArangoDB LINQ提供程序中使用
AQL Functions,您应该使用ArangoDB.Client.AQL静态方法.
对于您的用例,您可以在AQL函数中使用: var result = db.Query<movies>() .Where(p => AQL.In(id,p.categories)) .ToList(); 转换为: for `p` in `movies` filter @P1 in `p`.`categories` return `p` ArangoDB LINQ提供程序目前不支持像List这样的c#数据结构的内置方法 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |