public MySmo.UserDefinedTableType GetUserDefinedTableType(Smo.UserDefinedTableType smo_tt, MySmo.Database parent = null) { #region implement SetDataLimit(); var mysmo_tt = new MySmo.UserDefinedTableType(); mysmo_tt.ParentDatabase = parent; mysmo_tt.Name = smo_tt.Name; mysmo_tt.Schema = smo_tt.Schema; mysmo_tt.CreateTime = smo_tt.CreateDate; mysmo_tt.Owner = smo_tt.Owner; mysmo_tt.ExtendedProperties = GetExtendProperties(mysmo_tt, smo_tt.ExtendedProperties); var s = ""; if (mysmo_tt.ExtendedProperties.TryGetValue(K_MS_Description, out s)) { mysmo_tt.Description = s; mysmo_tt.ExtendedProperties.Remove(K_MS_Description); } mysmo_tt.Columns = new List <MySmo.Column>(); foreach (Smo.Column smo_c in smo_tt.Columns) { var mysmo_c = new MySmo.Column { ParentDatabase = parent, ParentTableBase = mysmo_tt, 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.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_tt.Columns.Add(mysmo_c); } FormatExtendProperties(mysmo_tt); return(mysmo_tt); #endregion }
public MySmo.DefaultConstraint GetDefaultConstraint(Smo.Column smo_c, MySmo.Column parentColumn, MySmo.Database parentDatabase = null) { var dc = smo_c.DefaultConstraint; if (dc == null) { return(null); } var result = new MySmo.DefaultConstraint { CreateTime = dc.CreateDate, IsSystemNamed = dc.IsSystemNamed, Name = dc.Name, Text = dc.Text, ParentColumn = parentColumn, ParentDatabase = parentDatabase }; result.ExtendedProperties = GetExtendProperties(result, dc.ExtendedProperties); return(result); }
public MySmo.UserDefinedFunction GetUserDefinedFunction(Smo.UserDefinedFunction smo_f, MySmo.Database parent = null) { #region implement SetDataLimit(); var mysmo_f = new MySmo.UserDefinedFunction(); mysmo_f.ParentDatabase = parent; mysmo_f.Name = smo_f.Name; mysmo_f.Schema = smo_f.Schema; mysmo_f.CreateTime = smo_f.CreateDate; mysmo_f.Owner = smo_f.Owner; mysmo_f.ExtendedProperties = GetExtendProperties(mysmo_f, smo_f.ExtendedProperties); var s = ""; if (mysmo_f.ExtendedProperties.TryGetValue(K_MS_Description, out s)) { mysmo_f.Description = s; mysmo_f.ExtendedProperties.Remove(K_MS_Description); } mysmo_f.Parameters = new List <MySmo.Parameter>(); foreach (Smo.UserDefinedFunctionParameter smo_p in smo_f.Parameters) { var mysmo_p = new MySmo.Parameter { ParentDatabase = parent, ParentParameterBase = mysmo_f, Name = smo_p.Name.Substring(1), DefaultValue = smo_p.DefaultValue, IsOutputParameter = false, IsReadOnly = smo_p.IsReadOnly, DataType = new MySmo.DataType { Name = smo_p.DataType.Name, Schema = smo_p.DataType.Schema, MaximumLength = smo_p.DataType.MaximumLength, NumericPrecision = smo_p.DataType.NumericPrecision, NumericScale = smo_p.DataType.NumericScale, SqlDataType = (MySmo.SqlDataType)(int) smo_p.DataType.SqlDataType } }; mysmo_f.Parameters.Add(mysmo_p); } if (smo_f.FunctionType == Smo.UserDefinedFunctionType.Table) { mysmo_f.Columns = new List <MySmo.Column>(); foreach (Smo.Column smo_c in smo_f.Columns) { var mysmo_c = new MySmo.Column { ParentDatabase = parent, ParentTableBase = mysmo_f, 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_f.Columns.Add(mysmo_c); } } FormatExtendProperties(mysmo_f); return(mysmo_f); #endregion }
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 }