I've been using Linq2Sql for the last few years and got used to a few features, like having an int
or tinyint
field in the DB, that I redefine in the DBML file to be of enum type, so it's nice and convenient to run a SQL query directly comparing to the enum (see here for my question 3 years ago on the subject, and the answer there).
Now I'm starting a project using Entity Framework 5, and while EF seems to have gotten many things right that L2S didn't (e.g. detach/reattach), I'm dismayed to see that there doesn't seem to be any easy way to change the C# type of such a field to be an enum.
Has anyone found a way to do this cleanly, so that I could have a query like:
var q = entities.Things.Where(t => t.Status == TStatus.Closed);
(and no, I don't want to have to cast to int
or byte
inline).