ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
Entity framework: Can not compare elements of type 'System.String []' in my multilookup controller
Title:
B
I
{code}
?
I need your help to fix a `NotSupportedException` in my multilookup controller. My GetItem method in the multilookup controller is public ActionResult GetItems(string[] v) { return Json(db.Activites.Where(o => v != null && v.Contains(o.IdActivity)).ToString() .Select(f => new KeyContent(f.IdActivite, f.NameActivity))); } But i have this error when i choose and validate some activities: _Can not compare elements of type 'System.String []'. Only primitive types, enumeration types and entity types are supported._ How can i solve it?
Save Changes
Cancel
ousmane.nacanabo
asked at 24 Mar 2014
put `.ToList()` before the `.Select` and take the `v != null` out of the query, this lambda expression gets transformed into a `sql` query by `EF`, and some stuff is not able to parse, so it told you that it can't compare string[]
at 24 Mar 2014
Omu
Yes, thank you very much. It's ok now
at 24 Mar 2014
ousmane.nacanabo
Answers
please
Sign In
to leave an answer
By accessing this site, you agree to store cookies on your device and disclose information in accordance with our
cookie policy
and
privacy policy
.
OK