Rachael
Rachael

Reputation: 1995

How does c# interpret my query?

Why does:

 var allShapes = _context.AttributeValuesLibraries.Where(x => x.AttNameID.Equals(1)).Select(y => y);

work, but I get the error "Unable to create a constant value of type 'System.Object'. Only primitive types or enumeration types are supported in this context" when I exclude the Select() like:

var allShapes = _context.AttributeValuesLibraries.Where(x => x.AttNameID.Equals(1));

Is there another way to write this query so it makes more sense? I just played with the query to make it work.

Thanks in advance!

Upvotes: 2

Views: 104

Answers (1)

Daniel A. White
Daniel A. White

Reputation: 191058

Try this:

var allShapes = _context.AttributeValuesLibraries.Where(x => x.AttNameID == 1);

It really depends on your Linq provider.

Upvotes: 3

Related Questions