Пример #1
0
        public DbCategory GetDbExplorer(string connName)
        {
            DbCategory       dbCategory = new DbCategory();
            ConnectionSchema connSchema = db.GetSchema().Connections.GetItem(connName);

            return(GetDbExplorer(connSchema));
        }
Пример #2
0
        public DbCategory GetDbExplorer(ConnectionSchema conSchema)
        {
            DbCategory dbCategory = new DbCategory();

            dbCategory.DbName  = conSchema.Id;
            dbCategory.DbTitle = conSchema.Title;

            if (string.IsNullOrEmpty(dbCategory.DbTitle))
            {
                dbCategory.DbTitle = dbCategory.DbName;
            }

            DbConnection conn = null;

            try
            {
                conn = db.GetConnection(conSchema.Id);
            }
            catch (Exception e)
            {
                dbCategory.Err = e.Message;
                return(dbCategory);
            }

            DataTable dt = conn.GetSchema("Tables");
            DataView  dv = dt.DefaultView;

            dv.Sort = "TABLE_NAME";

            foreach (DataRowView dr in dv)
            {
                ObjectDocket od = new ObjectDocket();

                od.Name  = dr["TABLE_NAME"].ToString();
                od.Title = dr["TABLE_NAME"].ToString();

                string tbType = dr["TABLE_TYPE"].ToString();


                if (tbType.Equals("VIEW"))
                {
                    dbCategory.Views.Add(od);
                }
                // if (tbType.Equals("TABLE"))
                else
                {
                    if (!od.Name.Equals("sysdiagrams", StringComparison.OrdinalIgnoreCase))
                    {
                        if (!od.Name.Equals("dtproperties", StringComparison.OrdinalIgnoreCase))
                        {
                            dbCategory.Tables.Add(od);
                        }
                    }
                }
            }
            return(dbCategory);
        }