代码之家  ›  专栏  ›  技术社区  ›  Biff MaGriff

Linq问题:类型的表达式系统字符串[]”不是序列

  •  1
  • Biff MaGriff  · 技术社区  · 15 年前

    所以我做了一个函数,返回字符串上的任何匹配。

    var results = (from d in db.MyData
    where new string[]{ d.DataField1.ToString(), d.DataField2.ToString(), ... }.Contains(searchTerm)
    select d);
    

    The expression of type 'System.String[]' is not a sequence.

    //blows up on first iteration
    foreach(var v in results)
    {...}
    

    谁能给我一些建议吗?

    谢谢!

    1 回复  |  直到 15 年前
        1
  •  3
  •   Scott Stafford    15 年前

    var results = (from d in db.MyData
      where d.DataField1.Contains(searchTerm) || d.DataField2.Contains(searchTerm)
      select d);
    
    推荐文章