Exemplo n.º 1
0
        protected void RemoveCachedSchema()
        {
            TableCacheKey key = new TableCacheKey(GetType(), ConnectionString, TableSchema, Table);

            lock (_cachedSchemas)
            {
                if (_cachedSchemas.ContainsKey(key))
                {
                    _cachedSchemas.Remove(key);
                }
            }
        }
Exemplo n.º 2
0
        public DataTable GetSchemaTable(bool forceCreateNew)
        {
            if (forceCreateNew)
            {
                RemoveCachedSchema();
            }

            TableCacheKey key = new TableCacheKey(GetType(), ConnectionString, TableSchema, Table);
            DataTable     tbl;

            if (!_cachedSchemas.TryGetValue(key, out tbl))
            {
                DataTable tb = BuildSchemaTable(); ///this may take some time
                lock (_cachedSchemas)
                    if (!_cachedSchemas.TryGetValue(key, out tbl))
                    //check again in case a matching schema has been created
                    {
                        _cachedSchemas.Add(key, tb);
                        tbl = tb;
                    }
            }

            return(tbl.Clone());
        }