2016-08-05 68 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