2016-08-05 70 views
1

我的约会数据库有Appointment ID, Status(enum type), Student作为列值。查询C#中DB的枚举值

这是Status枚举:

public enum StatusType 
{ 
    Pending, 
    Approved, 
    Cancelled 
} 

我需要查询的分贝(约会)行的列表,其中Status列设置为'Pending'并将它传递给一个列表变量。

如何在使用C#的Visual Studio中执行此操作?

IEnumerable<Appointment> AppQuery = from appointment in _appointmentData.GetAll() 
              where appointment.Status???? 
              select appointment; 

注意:_appointmentData.GetAll()列出了数据库中的整个行。

+0

你试过'那里appointment.Status == StatusType.Pending' – mariocatch

+0

是什么状态在你的数据类型数据库? – Sherlock

回答

2

要看什么获取存储在数据库中有点,但对于使用.Equals

IEnumerable<Appointment> AppQuery = from appointment in _appointmentData.GetAll() 
     where appointment.Status.Equals(StatusType.Pending) 
     select appointment; 
+0

非常感谢。这工作! – re3el