1

My Appointment database has Appointment ID, Status(enum type), Student as column values.

This is the Status enum:

 public enum StatusType
{
    Pending,
    Approved,
    Cancelled
}

I need to query the list of rows in the db(appointments) where Status column is set to 'Pending' and pass it to a list variable.

How do I do that in Visual Studio using C#?

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

Note: _appointmentData.GetAll() lists the entire rows in the db.

2
  • Have you tried where appointment.Status == StatusType.Pending Commented Aug 5, 2016 at 2:31
  • what is the datatype of status in your database? Commented Aug 5, 2016 at 2:31

1 Answer 1

2

Depends a bit on what gets stored in your database, but what about using .Equals:

IEnumerable<Appointment> AppQuery = from appointment in _appointmentData.GetAll()
       where appointment.Status.Equals(StatusType.Pending)
       select appointment;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.