Esempio n. 1
0
 public void FormatExtendProperties(MySmo.Table mysmo_t)
 {
     CombineExtendProperties(mysmo_t.ExtendedProperties);
     DistributeExtendProperties((MySmo.ITableBase)mysmo_t);
 }
Esempio n. 2
0
        public MySmo.Table GetTable(Smo.Table smo_t, MySmo.Database parent = null)
        {
            #region implement
            SetDataLimit();

            var mysmo_t = new MySmo.Table();
            mysmo_t.ParentDatabase     = parent;
            mysmo_t.Name               = smo_t.Name;
            mysmo_t.Schema             = smo_t.Schema;
            mysmo_t.CreateTime         = smo_t.CreateDate;
            mysmo_t.Owner              = smo_t.Owner;
            mysmo_t.TriggersCount      = smo_t.Triggers.Count;
            mysmo_t.ExtendedProperties = GetExtendProperties(mysmo_t, smo_t.ExtendedProperties);
            var s = "";
            if (mysmo_t.ExtendedProperties.TryGetValue(K_MS_Description, out s))
            {
                mysmo_t.Description = s;
                mysmo_t.ExtendedProperties.Remove(K_MS_Description);
            }
            mysmo_t.Columns = new List <MySmo.Column>();
            foreach (Smo.Column smo_c in smo_t.Columns)
            {
                var mysmo_c = new MySmo.Column
                {
                    ParentDatabase    = parent,
                    ParentTableBase   = mysmo_t,
                    Name              = smo_c.Name,
                    DataType          = GetDataType(smo_c),
                    Computed          = smo_c.Computed,
                    ComputedText      = smo_c.ComputedText,
                    Default           = smo_c.Default,
                    Identity          = smo_c.Identity,
                    IdentityIncrement = smo_c.IdentityIncrement,
                    IdentitySeed      = smo_c.IdentitySeed,
                    InPrimaryKey      = smo_c.InPrimaryKey,
                    IsForeignKey      = smo_c.IsForeignKey,
                    Nullable          = smo_c.Nullable,
                    RowGuidCol        = smo_c.RowGuidCol
                };
                mysmo_c.DefaultConstraint  = GetDefaultConstraint(smo_c, mysmo_c, parent);
                mysmo_c.ExtendedProperties = GetExtendProperties(mysmo_c, smo_c.ExtendedProperties);
                s = "";
                if (mysmo_c.ExtendedProperties.TryGetValue(K_MS_Description, out s))
                {
                    mysmo_c.Description = s;
                    mysmo_c.ExtendedProperties.Remove(K_MS_Description);
                }
                mysmo_t.Columns.Add(mysmo_c);
            }
            mysmo_t.ForeignKeys = new List <MySmo.ForeignKey>();
            foreach (Smo.ForeignKey smo_fk in smo_t.ForeignKeys)
            {
                var mysmo_fk = new MySmo.ForeignKey
                {
                    ParentDatabase              = parent,
                    Columns                     = new List <MySmo.ForeignKeyColumn>(),
                    CreateTime                  = smo_fk.CreateDate,
                    DeleteAction                = (MySmo.ForeignKeyAction)(int) smo_fk.DeleteAction,
                    IsChecked                   = smo_fk.IsChecked,
                    IsEnabled                   = smo_fk.IsEnabled,
                    IsSystemNamed               = smo_fk.IsSystemNamed,
                    Name                        = smo_fk.Name,
                    NotForReplication           = smo_fk.NotForReplication,
                    ParentTable                 = mysmo_t,
                    ReferencedKey               = smo_fk.ReferencedKey,
                    ReferencedTable             = smo_fk.ReferencedTable,
                    ReferencedTableSchema       = smo_fk.ReferencedTableSchema,
                    ScriptReferencedTable       = smo_fk.ScriptReferencedTable,
                    ScriptReferencedTableSchema = smo_fk.ScriptReferencedTableSchema,
                    UpdateAction                = (MySmo.ForeignKeyAction)(int) smo_fk.UpdateAction
                };
                foreach (Smo.ForeignKeyColumn smo_fkc in smo_fk.Columns)
                {
                    var mysmo_fkc = new MySmo.ForeignKeyColumn
                    {
                        ParentDatabase   = parent,
                        Name             = smo_fkc.Name,
                        ParentForeignKey = mysmo_fk,
                        ReferencedColumn = smo_fkc.ReferencedColumn
                    };
                    mysmo_fk.Columns.Add(mysmo_fkc);
                }
                mysmo_fk.ExtendedProperties = GetExtendProperties(mysmo_fk, smo_fk.ExtendedProperties);
                mysmo_t.ForeignKeys.Add(mysmo_fk);
            }
            FormatExtendProperties(mysmo_t);

            return(mysmo_t);

            #endregion
        }