public void Fill(Database database, string connectionString)
        {
            ICode code = null;
            try
            {
                if ((database.Options.Ignore.FilterStoreProcedure) || (database.Options.Ignore.FilterView) || (database.Options.Ignore.FilterFunction) || (database.Options.Ignore.FilterTrigger))
                {
                    root.RaiseOnReading(new ProgressEventArgs("Reading Text Objects...", Constants.READING_TEXTOBJECTS));
                    using (SqlConnection conn = new SqlConnection(connectionString))
                    {
                        using (SqlCommand command = new SqlCommand(GetSQL(database.Options), conn))
                        {
                            conn.Open();
                            command.CommandTimeout = 0;
                            using (SqlDataReader reader = command.ExecuteReader())
                            {
                                while (reader.Read())
                                {
                                    code = null;
                                    root.RaiseOnReadingOne(reader["name"]);
                                    string type = reader["Type"].ToString().Trim();
                                    string name = reader["name"].ToString();
                                    string definition = reader["Text"].ToString();
                                    int id = (int)reader["object_id"];
                                    if (type.Equals("V"))
                                        code = (ICode)database.Views.Find(id);

                                    if (type.Equals("TR"))
                                        code = (ICode)database.Find(id);

                                    if (type.Equals("P"))
                                        ((ICode)database.Procedures.Find(id)).Text = GetObjectDefinition(type, name, definition);

                                    if (type.Equals("IF") || type.Equals("FN") || type.Equals("TF"))
                                        code = (ICode)database.Functions.Find(id);

                                    if (code != null)
                                        code.Text = reader["Text"].ToString();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public void Fill(Database database, string connectionString, List<MessageLog> messages)
 {
     ISQLServerSchemaBase parent;
     try
     {
         if (database.Options.Ignore.FilterExtendedPropertys)
         {
             using (SqlConnection conn = new SqlConnection(connectionString))
             {
                 using (SqlCommand command = new SqlCommand(GetSQL(), conn))
                 {
                     conn.Open();
                     command.CommandTimeout = 0;
                     using (SqlDataReader reader = command.ExecuteReader())
                     {
                         while (reader.Read())
                         {
                             ExtendedProperty item = new ExtendedProperty(null);
                             if (((byte)reader["Class"]) == 5)
                             {
                                 item.Level0type = "ASSEMBLY";
                                 item.Level0name = reader["AssemblyName"].ToString();
                             }
                             if (((byte)reader["Class"]) == 1)
                             {
                                 string ObjectType = GetTypeDescription(reader["type"].ToString().Trim());
                                 item.Level0type = "SCHEMA";
                                 item.Level0name = reader["Owner"].ToString();
                                 if (!ObjectType.Equals("TRIGGER"))
                                 {
                                     item.Level1name = reader["ObjectName"].ToString();
                                     item.Level1type = ObjectType;
                                 }
                                 else
                                 {
                                     item.Level1type = "TABLE";
                                     item.Level1name = reader["ParentName"].ToString();
                                     item.Level2name = reader["ObjectName"].ToString();
                                     item.Level2type = ObjectType;
                                 }
                             }
                             if (((byte)reader["Class"]) == 6)
                             {
                                 item.Level0type = "SCHEMA";
                                 item.Level0name = reader["OwnerType"].ToString();
                                 item.Level1name = reader["TypeName"].ToString();
                                 item.Level1type = "TYPE";
                             }
                             if (((byte)reader["Class"]) == 7)
                             {
                                 item.Level0type = "SCHEMA";
                                 item.Level0name = reader["Owner"].ToString();
                                 item.Level1type = "TABLE";
                                 item.Level1name = reader["ObjectName"].ToString();
                                 item.Level2type = reader["class_desc"].ToString();
                                 item.Level2name = reader["IndexName"].ToString();                                        
                             } 
                             item.Value = reader["Value"].ToString();
                             item.Name = reader["Name"].ToString();
                             parent = ((ISQLServerSchemaBase)database.Find(item.FullName));
                             if (parent != null)
                             {
                                 item.Parent = (ISchemaBase)parent;
                                 parent.ExtendedProperties.Add(item);
                             }
                             else
                                 messages.Add(new MessageLog(item.FullName + " not found in extended properties.", "", MessageLog.LogType.Error));
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         messages.Add(new MessageLog(ex.Message,ex.StackTrace, MessageLog.LogType.Error));
     }
 }