public List <SysDatabase> GetAllDatabase()
        {
            List <SysDatabase> list = null;

            string sql = "select 0 as Id,dbid,name from master..SysDatabases";

            using (var db = new T4CodeGeneratorDbContext("Server=.;Database=master;Trusted_Connection=True;"))
            {
                DbRawSqlQuery <SysDatabase> dbs = db.Database.SqlQuery <SysDatabase>(sql);
                if (dbs == null || dbs.Count() < 1)
                {
                    return(null);
                }
                list = dbs.ToList <SysDatabase>();
            }
            return(list);
        }
Exemplo n.º 2
0
        public List <SysTable> GetSysViewsByDbName(string dbName)
        {
            List <SysTable> list = null;

            string sql = "select 0 as Id, [object_id],name,[type] from sys.views where type='V'";

            using (var db = new T4CodeGeneratorDbContext("Server=.;Database=" + dbName + ";Trusted_Connection=True;"))
            {
                DbRawSqlQuery <SysTable> dbs = db.Database.SqlQuery <SysTable>(sql);
                if (dbs == null || dbs.Count() < 1)
                {
                    return(null);
                }
                list = dbs.ToList <SysTable>();
            }

            return(list);
        }