i have the following string array
and would like to convert the contents into a linq Where
clause like the following.
var words[] = new string [] { "aaa", "bbb", "ccc", "ddd" };
.Where(x => x.Word == "aaa" && x.Word == "bbb" &&
x.Word == "ccc" && x.Word == "ddd")
Cheers :)
This is actually for RavenDb and it's smart enough to convert that linq to a Lucene query with AND
's in there...
So i really need it to be &&
The Linq provider in RavenDB, when told to translate the linq to lucene, does the following..
.Where(x => x.Word == "aaa" && x.Word == "bbb")
get's translated to
Query:aaa AND Query:bbb
so please, i would really appreciate any help and not suggetions to use ||
. This is not linq to objects
or linq to ef
, etc..
.Where(x => words.Contains(x.Word))
UPD :这对于问题的初始修订完全有效
If you want to use &&
then you're asking for all the conditions to be satisfied. You could try the All
operator:
.Where(item => words.All(word => word == item));
This seems extremely counterintuitive but is worth a try!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.