【问题标题】:RavenDb: Check if List<string> contains Any in another List<string>RavenDb:检查 List<string> 是否包含另一个 List<string> 中的 Any
【发布时间】:2017-01-22 19:52:52
【问题描述】:

我试图在 ravendb-query 中查询两个 list&lt;string&gt; 以判断列表 B 是否包含列表 A 中的任何值。

但出现错误:无法从类型表达式中提取值:参数。

这是我的尝试:

public class Media
{
    public List<string> Directors
}

var anotherMedia = new Media() {Directors = new List<string>() {"A", "B", "C"}};


var mediaWithSameDirector = session.Query<Media, Media_Index>().
Where(o => o.Directors.Any(l1 => anotherMedia.Any(l2 => l1 == l2)))
.Take(10).ToList();

【问题讨论】:

    标签: linq ravendb


    【解决方案1】:

    您可以为此使用In:

    var mediaWithSameDirector = session.Query<Media, Media_Index>()
         .Where(o => o.Directors.In(anotherMedia)
         .Take(10) 
         .ToList();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-08-08
      • 2022-01-09
      • 2013-03-14
      • 2018-12-30
      • 2014-10-14
      • 1970-01-01
      • 2022-10-23
      • 1970-01-01
      相关资源
      最近更新 更多