Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }