dimanche 9 octobre 2016

If Statement inside LINQ Select Query

I has a table call Staff and has two field call StaffStatus and ParentStatus. I would like to display the Status as "Available" when StaffStatus AND ParentStatus are both "Available" and display the Status as "Unavailable" when either StaffStaus OR ParentStatus is "Unavailable".

Friend Function getAllUser(strInput As String) As IQueryable
getAllUser = From userDB In db.Staffs                    
             Select Status = userDB.UserStatus.Equals("Available") And userDB.ParentStatus.Equals("Available") ? "Available"  : (userDB.UserStatus.Equals("Unavailable") Or userDB.ParentStatus.Equals("Unavailable") ? "Unavailable")
End Function

But the code editor show : The character "?" cannot be used here and the Syntax error of first "(" at ": (userDB.UserStatus.Equals("Unavailable")". Any error with my code?

Aucun commentaire:

Enregistrer un commentaire