小编Dar*_*ren的帖子

Linq列表包含

我正在使用ArangoDB,我正在查询一个名为的集合movies.它的数据结构是categories一个字符串列表.

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;
};
Run Code Online (Sandbox Code Playgroud)

这是查询语句:

var result = db.Query<movies>()
            .Where(p => p.categories.Contains(id));
Run Code Online (Sandbox Code Playgroud)

id作为参数传递,我需要检索具有与id匹配的类别的所有电影.但是,上面的代码不起作用,因为result它给了我集合中的所有电影.

foreach (movies mov in result)
{
    if (mov.categories.Contains(id) == false)
    { continue; }

    // do something here
}
Run Code Online (Sandbox Code Playgroud)

奇怪的是当我遍历结果中的项目时,同样的函数会返回false一些项目.但它只是在Linq声明中不起作用.

有人知道我的查询语句有什么问题吗?

c# linq arangodb

6
推荐指数
1
解决办法
384
查看次数

标签 统计

arangodb ×1

c# ×1

linq ×1