Example #1
0
 public bool TryGetDbView(RdbDescriptor db, string dbViewId, out DbView dbView)
 {
     if (!_initialized)
     {
         Init();
     }
     if (!_dicById.ContainsKey(db))
     {
         dbView = null;
         return false;
     }
     return _dicById[db].TryGetValue(dbViewId, out dbView);
 }
Example #2
0
 public bool TryGetDbViewColumns(RdbDescriptor database, DbView view, out IReadOnlyDictionary<string, DbViewColumn> dbViewColumns)
 {
     if (!_initialized)
     {
         Init();
     }
     if (!_dic.ContainsKey(database))
     {
         dbViewColumns = new Dictionary<string, DbViewColumn>(StringComparer.OrdinalIgnoreCase);
         return false;
     }
     Dictionary<string, DbViewColumn> outDic;
     var r = _dic[database].TryGetValue(view, out outDic);
     dbViewColumns = outDic;
     return r;
 }
        /// <summary>
        /// Reads views schema from database
        /// </summary>
        private List<DbView> ReadViews()
        {
            List<DbView> result = new List<DbView>();

            using (DataTable views = _dbConnection.GetSchema("Views"))
            {
                foreach (DataRow row in views.Rows)
                {
                    string viewName = row["TABLE_NAME"].ToString();
                    string ownerName = row["TABLE_SCHEMA"].ToString();

                    if (!IsViewSelected(viewName))
                        continue;

                    // View columns
                    List<DbColumn> columns = ReadColumns(viewName, ownerName);

                    // read columns description
                    if (ReadColumnsDescription)
                        ApplyColumnsDescription(viewName, columns);

                    // new view
                    var view = new DbView(viewName, columns);

                    // view schema
                    view.OwnerName = ownerName;

                    // add to results
                    result.Add(view);
                }
            }
            return result;
        }
        /// <summary>
        /// Reads views schema from database
        /// </summary>
        private List<DbView> ReadViews()
        {
            List<DbView> result = new List<DbView>();

            string[] restrictions = null;
            if (!string.IsNullOrWhiteSpace(this.SpecificOwner))
            {
                restrictions = new string[] { SpecificOwner.ToUpper() };
            }

            using (DataTable views = _dbConnection.GetSchema("Views", restrictions))
            {
                foreach (DataRow row in views.Rows)
                {
                    string viewName = row["VIEW_NAME"].ToString();

                    if (!IsViewSelected(viewName))
                        continue;

                    // View columns
                    List<DbColumn> columns = ReadColumns(viewName);

                    // new view
                    var view = new DbView(viewName, columns);

                    // view schema
                    view.OwnerName = row["OWNER"].ToString();

                    // add to results
                    result.Add(view);
                }
            }
            return result;
        }