public static async Task<List<ChallanType>> RetrieveAllChallanTypes() { List<ChallanType> typeList = new List<ChallanType>(); string sqlCmdString = "Select * From dbo.challan_types"; Database myDb = new Database(); SqlCommand sqlCmd = new SqlCommand(sqlCmdString, myDb.Connection); SqlDataAdapter sqlAdapt = new SqlDataAdapter(sqlCmd); DataTable table = new DataTable(); ChallanType challanType = null; await Task.Run(() => { try { myDb.OpenConnection(); sqlAdapt.Fill(table); foreach (DataRow row in table.Rows) { challanType = new ChallanType() { TypeName = (String)row["type_name"], IsPersist = true }; typeList.Add(challanType); } } finally { sqlAdapt.Dispose(); table.Dispose(); myDb.CloseConnection(); } }); return typeList; }
public static async Task <List <ChallanType> > RetrieveAllChallanTypes() { List <ChallanType> typeList = new List <ChallanType>(); string sqlCmdString = "Select * From dbo.challan_types"; Database myDb = new Database(); SqlCommand sqlCmd = new SqlCommand(sqlCmdString, myDb.Connection); SqlDataAdapter sqlAdapt = new SqlDataAdapter(sqlCmd); DataTable table = new DataTable(); ChallanType challanType = null; await Task.Run(() => { try { myDb.OpenConnection(); sqlAdapt.Fill(table); foreach (DataRow row in table.Rows) { challanType = new ChallanType() { TypeName = (String)row["type_name"], IsPersist = true }; typeList.Add(challanType); } } finally { sqlAdapt.Dispose(); table.Dispose(); myDb.CloseConnection(); } }); return(typeList); }