public async Task <List <IEmployee> > QueryAllAsync() { Connection = new SqlConnection("Data Source=DESKTOP-0NGMPOG;Initial Catalog=CompanyDB;Trusted_Connection=True;"); using (Connection) { bool error = false; SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM Employees " + Filtering.GenerateString() + " " + Sorting.GenerateString() + " " + Paging.GenerateString() + ";", Connection); Connection.Open(); DataSet dataSet = new DataSet(); await Task.Run(() => { try { adapter.Fill(dataSet, "Employees"); } catch { error = true; } } ); if (error) { return new List <IEmployee> { } } ; List <IEmployee> retVal = new List <IEmployee>(); foreach (DataRow pRow in dataSet.Tables[0].Rows) { retVal.Add(new Employee() { Id = Guid.Parse(pRow.ItemArray.GetValue(0).ToString()), FirstName = pRow.ItemArray.GetValue(1).ToString(), LastName = pRow.ItemArray.GetValue(2).ToString(), Department = pRow.ItemArray.GetValue(3).ToString() }); } return(retVal); } }