2016-08-05 9 views
1

My Appointmentデータベースの列値はAppointment ID, Status(enum type), Studentです。C#でのDBからのenum値の照会

これはStatus列挙です:

public enum StatusType 
{ 
    Pending, 
    Approved, 
    Cancelled 
} 

は私がStatus列が'Pending'に設定され、リスト変数に渡しているデシベル(予定)の行のリストを照会する必要があります。

Visual StudioでC#を使用してどのように行うことができますか?

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

注:_appointmentData.GetAll()は、dbの行全体をリストします。

+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

関連する問題