Beispiel #1
0
        private List <string> GetDbObjectNames(string type, params string[] exceptNames)
        {
            var names = new List <string>();
            var sb    = new StringBuilder();

            if (exceptNames != null)
            {
                foreach (string name in exceptNames)
                {
                    sb.AppendFormat(" AND [Name]!='{0}'", name);
                }
            }
            string commandText = string.Format("SELECT [Name] FROM [sysobjects] WHERE [type]='{0}'{1} ORDER BY [Name]",
                                               type, sb);

            try
            {
                DbAccessCommand dbcmd = GetDbAccessCommand();
                dbcmd.AttachAccessInfo(commandText, new DbParameter[0]);
                DataTable table = dbcmd.ExecuteDataTable();
                names.AddRange(from DataRow row in table.Rows select(string) row[0]);
            }
            catch
            {
            }
            return(names);
        }
Beispiel #2
0
        public List <VersionInfo> GetAllVersion()
        {
            const string    commandText = @"SELECT * FROM [VersionInfo]";
            DbAccessCommand dbcmd       = GetDbAccessCommand();

            dbcmd.AttachAccessInfo(commandText, new DbParameter[0]);
            DataTable table = dbcmd.ExecuteDataTable();

            return((from DataRow row in table.Rows
                    select new VersionInfo
            {
                Version = (long)row[0], AppliedOn = (DateTime?)row[1], Description = (string)row[2]
            }).ToList());
        }
Beispiel #3
0
        public XmlDocument GetSchema(string baseName)
        {
            string          sqlString    = string.Format("SELECT TOP 1 * FROM [{0}]", baseName);
            string          dessqlString = string.Format("SELECT [Table Name] = i_s.TABLE_NAME,  [Column Name] = i_s.COLUMN_NAME,  [Description] = s.value FROM  INFORMATION_SCHEMA.COLUMNS i_s LEFT OUTER JOIN  sys.extended_properties s ON  s.major_id = OBJECT_ID(i_s.TABLE_SCHEMA+'.'+i_s.TABLE_NAME)  AND s.minor_id = i_s.ORDINAL_POSITION   AND s.name = 'MS_Description' WHERE  OBJECTPROPERTY(OBJECT_ID(i_s.TABLE_SCHEMA+'.'+i_s.TABLE_NAME), 'IsMsShipped')=0 AND i_s.TABLE_NAME = '{0}' ORDER BY  i_s.TABLE_NAME, i_s.ORDINAL_POSITION", baseName);
            DbAccessCommand dbcmd        = CodeGenerator.Instance.GetDbAccessCommand();

            dbcmd.AttachAccessInfo(sqlString, new DbParameter[0]);
            DataTable schemaTable = dbcmd.ExecuteSchemaTable();

            dbcmd.AttachAccessInfo(dessqlString, new DbParameter[0]);
            DataTable DescriptionTable = dbcmd.ExecuteDataTable();

            return(CodeGenerator.Instance.CreateDbSchemaDocument(schemaTable, baseName, DescriptionTable));
        }