I got one big question.
I got a linq query to put it simply looks like this:
from xx in table
where xx.uid.ToString().Contains(string[])
select xx
The values of the string[]
array would be numbers like (1,45,20,10,etc...)
the Default for .Contains
is .Contains(string)
.
I need it to do this instead: .Contains(string[])
...
EDIT : One user suggested writing an extension class for string[]
. I would like to learn how, but any one willing to point me in the right direction?
EDIT : The uid would also be a number. That's why it is converted to a string.
Help anyone?
You should write it the other way around, checking your priviliged user id list contains the id on that row of table:
LINQ behaves quite bright here and converts it to a good SQL statement:
which basicly embeds the contents of the 'search' array into the sql query, and does the filtering with 'IN' keyword in SQL.
Try:
I believe you could also do something like this.
This is an example of one way of writing an extension method (note: I wouldn't use this for very large arrays; another data structure would be more appropriate...):
LINQ in .NET 4.0 has another option for you; the .Any() method;
Or if you already have the data in a list and prefer the other Linq format :)