public static async Task <List <Doctor> > SearchDoctor(string DoctorName, int SpecialityID, int HospitalID) { List <Doctor> doctorList = new List <Doctor>(); Doctor doctor = null; List <SP_SEARCH_DOCTORResult> result = null; using (LinqDBDataContext data = new LinqDBDataContext()) { result = await Task.Run(() => data.SP_SEARCH_DOCTOR(DoctorName, SpecialityID, HospitalID).ToList()); } foreach (SP_SEARCH_DOCTORResult r in result) { doctor = new Doctor(); doctor.Doctor_ID = r.Doctor_ID; doctor.First_Name = r.First_Name; doctor.Last_Name = r.Last_Name; doctor.Degree = r.Degree; doctor.Experience = r.Experience; doctor.Working_Day = r.Working_Day; doctor.Photo_ID = r.Photo_ID; doctorList.Add(doctor); } return(doctorList); }