예제 #1
0
        /// <summary>
        /// Returns a list of table sources (e.g. tables, views) that belong to a given database.
        /// The returned table sources must have different display names.
        /// </summary>
        /// <param name="database">Database from which we want to fetch the list of tables</param>
        /// <param name="isTableSourceToIgnore">The delegate to call to see if the table source should be ignored and excluded from the returned list</param>
        /// <returns>List of available table sources in the given database</returns>
        /// <exception cref="System.Data.Common.DbException">if an error occurs while accessing the database</exception>
        public override IEnumerable <ITableSourceInfo> ListTableSources(IDatabaseInfo database, IsTableSourceToIgnore isTableSourceToIgnore)
        {
            IList <ITableSourceInfo> tables       = new List <ITableSourceInfo>();
            CacheDatabaseInfo        databaseInfo = database as CacheDatabaseInfo;

            if (databaseInfo == null)
            {
                return(null);
            }
            using (IDbConnection conn = DatabaseServices.TransactionService.CreateConnection()) {
                string sql = string.Format(@"SELECT SqlQualifiedNameQ, SqlTableName FROM %Dictionary.CompiledClass  
                                             WHERE SqlSchemaName = '{0}'
                                               AND ClassType IN ('persistent', 'view')", databaseInfo.Identifier);

                IDbCommand cmd = DatabaseServices.ExecutionService.CreateCommand(conn, sql);
                cmd.CommandTimeout = QueryTimeout;
                using (IDataReader reader = cmd.ExecuteReader()) {
                    while (reader.Read())
                    {
                        string tableName          = (string)reader["SqlTableName"];
                        string qualifiedTableName = (string)reader["SqlQualifiedNameQ"];
                        if (!isTableSourceToIgnore(tableName))
                        {
                            tables.Add(new CacheTableSourceInfo(DatabaseServices, databaseInfo, tableName, qualifiedTableName));
                        }
                    }
                }
            }
            return(tables);
        }
예제 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CacheTableSourceInfo"/> class.
 /// </summary>
 /// <param name="databaseServices">The database services.</param>
 /// <param name="database">The database.</param>
 /// <param name="name">The name.</param>
 /// <param name="qualifiedName">Name of the qualified.</param>
 public CacheTableSourceInfo(IDatabaseServices databaseServices, CacheDatabaseInfo database, string name, string qualifiedName)
     : base(databaseServices, database, name, qualifiedName)
 {
 }