我有以下代码:
string s = "123,12346";
bool b = s.Contains("1234");
以上返回true,但是有没有办法返回false。我已经做了类似的事情:
string[] s = {"123","12346"};
bool b = s.Contians("1234");
以上有效,但我不能在 contains 表达式中使用以上内容,LINQ-To-Entities因为它不喜欢 Contains in pre EF 4.0。
我有一个扩展方法,它的行为类似于SQL IN子句,但是我需要在使用它时显式键入参数,我不知道在括号之间放什么:
predicate = predicate(x=> WhereIn<>(x.Id, Ids));
x.Id is a string and Ids is a string也是。如果我把WhereIn<string,string>它抱怨说Argument type string is not assignable to parameter type ObjectQuery<string>
predicate来自PredicateBuilder:http ://www.albahari.com/nutshell/predicatebuilder.aspx