Is there a way to exclude a list of values for an object attribute when querying the database through entity framework?
I tried to be slick and pull this number:
List<String> StringList = new List<String>();
StringList.Add("ya_mama");
StringList.Add("has");
StringList.Add("fleas");
servicesEntities context = new servicesEntities();
var NoFleasQuery = (from x in context.person
where !StringList.Any(y => y.CompareTo(x.the_string_I_dont_want_it_to_be) == 0) // <--- the part where I thought I was slick
select x);
It compiled, but after I ran it, it gave me this error:
Unable to create a constant value of type 'Closure type'. Only primitive types ('such as Int32, String, and Guid') are supported in this context.
'Closure type'?? How about MY closure!! Entity framework... you broke my heart.