public static List <T> GetEntityListByQuery <T>(SqlCommand sqlCMD) { CRUDOperation objCRUD = new CRUDOperation(); List <T> data = new List <T>(); try { using (DataTable dt = objCRUD.getDataTableByQuery(sqlCMD)) { foreach (DataRow row in dt.Rows) { T item = GetItem <T>(row); data.Add(item); } } } catch (Exception ex) { Console.WriteLine("Exception : " + ex.Message); sqlCMD.Connection.Close(); sqlCMD.Dispose(); //throw; } finally { objCRUD = null; sqlCMD.Connection.Close(); sqlCMD.Dispose(); } return(data); }
public static List <T> GetEntityList <T>(SqlCommand sqlCMD) { CRUDOperation objCRUD = new CRUDOperation(); List <T> data = new List <T>(); try { using (DataTable dt = objCRUD.getDataTable(sqlCMD)) { foreach (DataRow row in dt.Rows) { T item = GetItem <T>(row); data.Add(item); } } } catch (Exception) { sqlCMD.Connection.Close(); sqlCMD.Dispose(); throw; } finally { objCRUD = null; sqlCMD.Connection.Close(); sqlCMD.Dispose(); } return(data); }
public static DataTable GetDataTableByQuery(SqlCommand sqlCMD) { DataTable dt = new DataTable(); try { dt = new CRUDOperation().getDataTableByQuery(sqlCMD); } catch (Exception) { dt = new DataTable(); sqlCMD.Connection.Close(); sqlCMD.Dispose(); throw; } finally { sqlCMD.Connection.Close(); sqlCMD.Dispose(); } return(dt); }