Esempio n. 1
0
        public List <TEntity> GetList <TEntity>(string connectionString, string sqlString) where TEntity : class, new()
        {
            List <TEntity> list = new List <TEntity>();

            using (DataSet ds = DBHelperMySQL.Create(connectionString).Query(sqlString))
            {
                if (ds == null)
                {
                    return(list);
                }

                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    list = ds.Tables[0].ConvertToList <TEntity>();
                }
            }

            return(list);
        }
Esempio n. 2
0
        public TEntity GetEntityByProcedure <TEntity>(string connectionString, string procedureName, params MySqlParameter[] parameters) where TEntity : class, new()
        {
            TEntity entity = null;

            using (DataSet ds = DBHelperMySQL.Create(connectionString).RunProcedure(procedureName, parameters))
            {
                if (ds == null)
                {
                    return(entity);
                }

                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    entity = ds.Tables[0].Rows[0].ConvertToModel <TEntity>();
                }
            }

            return(entity);
        }
Esempio n. 3
0
        public List <TValue> GetValues <TValue>(string connectionString, string sqlString, params MySqlParameter[] parameters)
        {
            List <TValue> list = new List <TValue>();

            using (DataSet ds = DBHelperMySQL.Create(connectionString).Query(sqlString, parameters))
            {
                if (ds == null)
                {
                    return(list);
                }

                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    list = ds.Tables[0].ConvertToValues <TValue>();
                }
            }

            return(list);
        }
Esempio n. 4
0
        public List <TEntity> GetListByProcedure <TEntity>(string connectionString, string procedureName, params MySqlParameter[] parameters) where TEntity : class, new()
        {
            List <TEntity> list = new List <TEntity>();

            using (DataSet ds = DBHelperMySQL.Create(connectionString).RunProcedure(procedureName, parameters))
            {
                if (ds == null)
                {
                    return(list);
                }

                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    list = ds.Tables[0].ConvertToList <TEntity>();
                }
            }

            return(list);
        }