Using Enums in Entity Framework Where Clause?

Just cast to begin with: public List FindAllOfEnum(MyEnum myEnum) { using (DbContext db = new DbContext()) { return db.MyClasses. Where(x => x. MyEnum == (int)myEnum); } }.

Nope, this would result in the same error I am getting: The specified type member 'MyEnum' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported. Edit: Actually, I get "Operator '==' – OpticalDelusion Nov 16 at 8:33 Edit: Actually, I get "Operator '=='cannot be applied to operands of type 'MyEnum' and 'int'".

And if I use Object. Equals, then I get the above error. – OpticalDelusion Nov 16 at 8:42 1 Right, what I intended there was to compare against the actual column: return db.MyClasses.

Where(x => x. Mycolumn == (int)myEnum); – Todd Bellamy Nov 16 at 14:03 Okay, thanks. That is what I have right now, I was hoping I didn't have to publicly expose the integer value though, alas.

– OpticalDelusion Nov 16 at 17:29.

This is not supported until next major version of EF (.NET 4.5). Until . NET 4.5 you must pass int to your queries (conversion must be done outside of your query).

The best workaround is this.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions