public Task <List <ProductDetails> > GetAllProducts() { List <ProductDetails> lstDetails = new List <ProductDetails>(); using (sqlConnection = new SqlConnection(connection)) { sqlCommand = new SqlCommand("select * from ProductDetails", sqlConnection); sqlConnection.Open(); using (var objDataReader = sqlCommand.ExecuteReader()) { while (objDataReader.Read()) { lstDetails.Add(ProductDetails.Fill((IDataRecord)objDataReader)); } } return(Task.FromResult(lstDetails)); } }