public DatabaseSearchResult(ScriptSchemaObjectBase result, SqlConnectionInfo connection, Database db)
        {
            DataBase = db;

            this.result     = result;
            this.connection = connection;

            if (result is Table)
            {
                ObjectType = ObjType.Table;
            }
            else if (result is StoredProcedure)
            {
                ObjectType = ObjType.StoredProc;
            }
            else if (result is View)
            {
                ObjectType = ObjType.View;
            }
            else if (result is UserDefinedFunction)
            {
                ObjectType = ObjType.Func;
            }
            else
            {
                throw new NotImplementedException("Unknown object type " + result.GetType().Name);
            }

            SearchName = SchemaAndName.ToLower();
        }
예제 #2
0
        private XmlNode ExtractObject(ScriptSchemaObjectBase obj)
        {
            bool ext = true;

            ext &= Constants.ObjectTypeMap.ContainsKey(obj.GetType());

            // Avoid metadata tables
            ext &= String.Compare(obj.Schema, Constants.SchemaMeta, true) != 0;

            // Avoid system views and tables
            ext &= String.Compare(obj.Schema, Constants.SchemaSys, true) != 0;
            ext &= String.Compare(obj.Schema, Constants.SchemaInfoSch, true) != 0;

            if (ext)
            {
                XmlNode node = xml.CreateElement(Constants.ObjectTypeMap[obj.GetType()].ToString().ToLower());

                node.Attributes.Append(xml.CreateAttribute(Constants.AttributeName)).Value = String.Format("[{0}].[{1}]", obj.Schema, obj.Name);

                foreach (ExtendedProperty p in ((IExtendedProperties)obj).ExtendedProperties)
                {
                    string pname = p.Name.Replace(Constants.SchemaMeta.ToLowerInvariant() + ".", String.Empty);

                    if (Constants.ObjectElements.Contains(pname))
                    {
                        node.AppendChild(xml.CreateElement(pname)).InnerText = p.Value.ToString();
                    }
                    else
                    {
                        // Assume all the rest is attribute
                        node.Attributes.Append(xml.CreateAttribute(pname)).Value = p.Value.ToString();
                    }
                }

                ExtractColumnsAndParameters(obj, node);

                return(node);
            }
            else
            {
                return(null);
            }
        }
예제 #3
0
        private XmlNode ExtractObject(ScriptSchemaObjectBase obj)
        {
            bool ext = true;

            ext &= Constants.ObjectTypeMap.ContainsKey(obj.GetType());

            // Avoid metadata tables
            ext &= String.Compare(obj.Schema, Constants.SchemaMeta, true) != 0;

            // Avoid system views and tables
            ext &= String.Compare(obj.Schema, Constants.SchemaSys, true) != 0;
            ext &= String.Compare(obj.Schema, Constants.SchemaInfoSch, true) != 0;

            if (ext)
            {
                XmlNode node = xml.CreateElement(Constants.ObjectTypeMap[obj.GetType()].ToString().ToLower());

                node.Attributes.Append(xml.CreateAttribute(Constants.AttributeName)).Value = String.Format("[{0}].[{1}]", obj.Schema, obj.Name);

                foreach (ExtendedProperty p in ((IExtendedProperties)obj).ExtendedProperties)
                {
                    string pname = p.Name.Replace(Constants.SchemaMeta.ToLowerInvariant() + ".", String.Empty);

                    if (Constants.ObjectElements.Contains(pname))
                    {
                        node.AppendChild(xml.CreateElement(pname)).InnerText = p.Value.ToString();
                    }
                    else
                    {
                        // Assume all the rest is attribute
                        node.Attributes.Append(xml.CreateAttribute(pname)).Value = p.Value.ToString();
                    }
                }

                ExtractColumnsAndParameters(obj, node);

                return node;
            }
            else
            {
                return null;
            }
        }