Tuesday, May 30, 2017

Unable to create a constant value of type 'Whatever+Whatever'. Only primitive types or enumeration types are supported in this context.

This IQueryable Entity Framework error appears when you are doing complicated mechanics to a second type midstream in a lambda expression where you are manipulating a collection of another type that you really mean to affect with IQueryable. The fix is to just recast the secondary collection to a different collection at a different line of code upstream from the line of code that is freaking out. If I have an IQueryable of Foo and I want to find all the Foo types that have an id that matches something similar in another collection called Bar, you may need to select the ids out of Bar to a list of Guids or integers independent of a line of code that is for IQueryable mechanics.

No comments:

Post a Comment