I have a field in my database table that is used to store an enumeration value, for example:
create table MyTable ( ... Status tinyint not null, ... )
and in my c # class i have
public enum TStatus : byte { Pending = 1 Active = 2, Inactive = 3, } public TStatus MyStatus { get { return (TStatus)Status; } set { Status = (byte)value; } }
now I want to write a Linq query that uses the MyStatus MyTable property, for example.
var q = MyDataContext.GetTable<MyTable>().Where(t => t.MyStatus == TStatus.Active);
but of course Linq doesn't know how to interpret MyStatus as SQL. What do I need to do for MyStatus to work in LinqToSQL?
source share