How do I use my enumeration in a LinqToSQL query?

前端 未结 2 1267
有刺的猬
有刺的猬 2021-01-03 15:08

I have a field in my database table that use to store an enumeration value, e.g.:

create table MyTable (
  ...
  Status tinyint not null,
  ...
)
         


        
2条回答
  •  悲哀的现实
    2021-01-03 15:27

    Don't have a compiler handy, but I think if you cast your enum to an int, it will work. So try:

    var q = MyDataContext.GetTable().Where(t => t.MyStatus == (int)TStatus.Active);

提交回复
热议问题