Possible Duplicate:
'Contains()' workaround using Linq to Entities?
Using LINQ in C#, I have the following problem;
I need to select rows from a big table, using 3 conditions: - "schooljaar" needs to be a value, set before, - "p_bamatype" needs to be a value NOT in a list defined in settings (this is a StringCollection) - "p_stdgeb" needs to be a value NOT in a list defined in settings (this is also a StringCollection)
I have this code:
var set = (db.SA_Opleiding.Where(opleiding => opleiding.schooljaar == schooljaar
&&
!Properties.Settings.Default.Admin_Studiegebieden_Exclude.Cast
<string>().ToList().Contains(
opleiding.p_stdgeb.ToString())
&&
!Properties.Settings.Default.Admin_Studietypes_Exclude.Cast
<string>().ToList().Contains(
opleiding.p_bamatype.ToString()))
.Select(opleiding => new OpleidingModel()
{
Id = opleiding.p_opleiding,
LanNames =
new Dictionary
<string, string>()
{
{
"NL",
opleiding.
opleidingNL
},
{
"FR",
opleiding.
opleidingFR
},
{
"EN",
opleiding.
opleidingEN
}
}
}))
.ToList<OpleidingModel>();
return set;
However, LINQ fails converting the Contains method. I read about others having the same issue, but I can't seem to find a decent solution for this. Is there really any solution for the problem described? So what I exactly need is a NOT IN (collection of strings) LINQ equivalent.