Esempio n. 1
0
        internal static DataSet GetEmptyEntityWithSchema(string selStr, string tableName, AbsDatabase db)
        {
            string key = selStr + db.GetRealOne().ConnectionString;

            if (hashEntitiesWithSchema.ContainsKey(key))
            {
                return((hashEntitiesWithSchema[key] as DataSet).Clone());
            }
            else
            {
                DataSet        ds      = new DataSet();
                IDbDataAdapter adapter = db.GetDataAdapter(selStr);
                adapter.FillSchema(ds, SchemaType.Source);
                ds.Tables[0].TableName      = tableName;
                hashEntitiesWithSchema[key] = ds;
                return(ds.Clone());
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 获得只包含表结构的DataSet,用于除_Default以外的数据源
        /// </summary>
        /// <param name="p_db">AbsDatabase对象</param>
        /// <param name="p_tableName">表名</param>
        /// <returns>DataSet</returns>
        public static DataSet GetEmptyEntity(AbsDatabase p_db, string p_tableName)
        {
            string key = p_db.GetRealOne().ConnectionString + p_tableName;

            if (!hashEntities.ContainsKey(key))
            {
                try
                {
                    string  tableName = p_tableName.Trim();
                    string  strSql    = string.Format("select * from {0} where 0=1", tableName);
                    DataSet ds        = p_db.GetEntity(strSql, tableName);
                    hashEntities.Add(key, ds);
                    return(ds.Clone());
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
            else
            {
                return((hashEntities[key] as DataSet).Clone());
            }
        }