private Model.View GetNewView(Microsoft.SqlServer.Management.Smo.View smoView) { Model.View view = new Model.View(smoView.Name, Script.GetSingluar(smoView.Name), false); // Columns int ordinalPosition = 0; List<Microsoft.SqlServer.Management.Smo.Column> smoColumns = new List<Microsoft.SqlServer.Management.Smo.Column>(); foreach (Microsoft.SqlServer.Management.Smo.Column smoColumn in smoView.Columns) { smoColumns.Add(smoColumn); } smoColumns.Sort(new SortComparer<Microsoft.SqlServer.Management.Smo.Column>("ID", System.ComponentModel.ListSortDirection.Ascending)); foreach (Microsoft.SqlServer.Management.Smo.Column smoColumn in smoColumns) { if (UnsupportedDataTypes.ToLower().IndexOf("'" + smoColumn.DataType.Name.ToLower() + "'") >= 0) { continue; } Model.Column column = new Model.Column(smoColumn.Name, Script.GetSingluar(smoColumn.Name), false, smoColumn.Name, view, ordinalPosition, smoColumn.Nullable, smoColumn.DataType.Name, smoColumn.DataType.MaximumLength, false, smoColumn.Identity, smoColumn.Default, true); view.AddColumn(column); ordinalPosition++; } return view; }
private Model.View GetNewView(string viewName) { ArchAngel.Interfaces.ProjectHelper.RaiseObjectBeingProcessedEvent(viewName, "View"); //_columns = null; Model.View view = new Model.View(viewName, false); #region Columns DataRow[] columnRows = Columns.Select(string.Format("TABLE_NAME = '{0}'", viewName)); foreach (DataRow columnRow in columnRows) { Column column = new Column( (string)columnRow["COLUMN_NAME"], false, view, (int)columnRow["ORDINAL_POSITION"], Slyce.Common.Utility.StringsAreEqual((string)columnRow["IS_NULLABLE"], "YES", false), (string)columnRow["DATA_TYPE"], columnRow.IsNull("CHARACTER_MAXIMUM_LENGTH") ? 0 : (int)columnRow["CHARACTER_MAXIMUM_LENGTH"], false, columnRow.IsNull("IsIdentity") ? false : (int)columnRow["IsIdentity"] == 1, columnRow.IsNull("COLUMN_DEFAULT") ? "" : (string)columnRow["COLUMN_DEFAULT"], columnRow.IsNull("IsComputed") ? false : (int)columnRow["IsComputed"] == 1); if (IsSupported(column)) { view.AddColumn(column); } } #endregion return(view); }
private Model.View GetNewView(SQLDMO.View dmoView) { Model.View view = new Model.View(dmoView.Name, Script.GetSingluar(dmoView.Name), false); // Columns int ordinalPosition = 0; List<SQLDMO.Column> dmoColumns = new List<SQLDMO.Column>(); SQLDMO.SQLObjectList sqlObjectList = dmoView.ListColumns(); foreach (SQLDMO.Column dmoColumn in sqlObjectList) { dmoColumns.Add(dmoColumn); } dmoColumns.Sort(new SortComparer<SQLDMO.Column>("ID", System.ComponentModel.ListSortDirection.Ascending)); foreach (SQLDMO.Column dmoColumn in dmoColumns) { if (UnsupportedDataTypes.ToLower().IndexOf("'" + dmoColumn.PhysicalDatatype.ToLower() + "'") >= 0) { continue; } Column column = new Column(dmoColumn.Name, Script.GetSingluar(dmoColumn.Name), false, dmoColumn.Name, view, ordinalPosition, dmoColumn.AllowNulls, dmoColumn.PhysicalDatatype, dmoColumn.Length, false, dmoColumn.Identity, dmoColumn.Default, true); view.AddColumn(column); ordinalPosition++; } return view; }
private Model.View GetNewView(SQLDMO.View dmoView) { Model.View view = new Model.View(dmoView.Name, Script.GetSingluar(dmoView.Name), false); // Columns int ordinalPosition = 0; List <SQLDMO.Column> dmoColumns = new List <SQLDMO.Column>(); SQLDMO.SQLObjectList sqlObjectList = dmoView.ListColumns(); foreach (SQLDMO.Column dmoColumn in sqlObjectList) { dmoColumns.Add(dmoColumn); } dmoColumns.Sort(new SortComparer <SQLDMO.Column>("ID", System.ComponentModel.ListSortDirection.Ascending)); foreach (SQLDMO.Column dmoColumn in dmoColumns) { if (UnsupportedDataTypes.ToLower().IndexOf("'" + dmoColumn.PhysicalDatatype.ToLower() + "'") >= 0) { continue; } Column column = new Column(dmoColumn.Name, Script.GetSingluar(dmoColumn.Name), false, dmoColumn.Name, view, ordinalPosition, dmoColumn.AllowNulls, dmoColumn.PhysicalDatatype, dmoColumn.Length, false, dmoColumn.Identity, dmoColumn.Default, true); view.AddColumn(column); ordinalPosition++; } return(view); }
private Model.View GetNewView(Microsoft.SqlServer.Management.Smo.View smoView) { Model.View view = new Model.View(smoView.Name, Script.GetSingluar(smoView.Name), false); // Columns int ordinalPosition = 0; List <Microsoft.SqlServer.Management.Smo.Column> smoColumns = new List <Microsoft.SqlServer.Management.Smo.Column>(); foreach (Microsoft.SqlServer.Management.Smo.Column smoColumn in smoView.Columns) { smoColumns.Add(smoColumn); } smoColumns.Sort(new SortComparer <Microsoft.SqlServer.Management.Smo.Column>("ID", System.ComponentModel.ListSortDirection.Ascending)); foreach (Microsoft.SqlServer.Management.Smo.Column smoColumn in smoColumns) { if (UnsupportedDataTypes.ToLower().IndexOf("'" + smoColumn.DataType.Name.ToLower() + "'") >= 0) { continue; } Model.Column column = new Model.Column(smoColumn.Name, Script.GetSingluar(smoColumn.Name), false, smoColumn.Name, view, ordinalPosition, smoColumn.Nullable, smoColumn.DataType.Name, smoColumn.DataType.MaximumLength, false, smoColumn.Identity, smoColumn.Default, true); view.AddColumn(column); ordinalPosition++; } return(view); }
private Model.View GetNewView(string viewName) { Interfaces.Events.RaiseObjectBeingProcessedEvent(viewName, "View"); //_columns = null; Model.View view = new Model.View(viewName, false); #region Columns DataRow[] columnRows = Columns.Select(string.Format("TABLE_NAME = '{0}'", viewName)); foreach (DataRow columnRow in columnRows) { bool isReadOnly = false; if (!columnRow.IsNull("IsIdentity") && (int)columnRow["IsIdentity"] == 1) { isReadOnly = true; } else if (!columnRow.IsNull("IsComputed") && (int)columnRow["IsComputed"] == 1) { isReadOnly = true; } else if (Slyce.Common.Utility.StringsAreEqual((string)columnRow["DATA_TYPE"], "timestamp", false)) { isReadOnly = true; } Column column = new Column( (string)columnRow["COLUMN_NAME"], false, view, (int)columnRow["ORDINAL_POSITION"], Slyce.Common.Utility.StringsAreEqual((string)columnRow["IS_NULLABLE"], "YES", false), (string)columnRow["DATA_TYPE"], columnRow.IsNull("CHARACTER_MAXIMUM_LENGTH") ? 0 : Convert.ToInt32(columnRow["CHARACTER_MAXIMUM_LENGTH"]), false, columnRow.IsNull("IsIdentity") ? false : Convert.ToInt32(columnRow["IsIdentity"]) == 1, columnRow.IsNull("COLUMN_DEFAULT") ? "" : (string)columnRow["COLUMN_DEFAULT"], isReadOnly, columnRow.IsNull("IsComputed") ? false : Convert.ToInt32(columnRow["IsComputed"]) == 1, columnRow.IsNull("NUMERIC_PRECISION") ? 0 : Convert.ToInt32(columnRow["NUMERIC_PRECISION"]), columnRow.IsNull("NUMERIC_SCALE") ? 0 : Convert.ToInt32(columnRow["NUMERIC_SCALE"])); if (IsSupported(column)) { view.AddColumn(column); } } #endregion return(view); }
private Model.View GetNewView(string viewName) { ArchAngel.Interfaces.Events.RaiseObjectBeingProcessedEvent(viewName, "View"); //_dtColumns = null; Model.View view = new Model.View(viewName, false); // Columns DataRow[] columnRows = DtColumns.Select(string.Format("TABLE_NAME = '{0}'", viewName)); foreach (DataRow row in columnRows) { bool isReadOnly = false; if (!row.IsNull("IsIdentity") && (int)row["IsIdentity"] == 1) { isReadOnly = true; } else if (!row.IsNull("IsComputed") && (int)row["IsComputed"] == 1) { isReadOnly = true; } else if (Slyce.Common.Utility.StringsAreEqual((string)row["DATA_TYPE"], "timestamp", false)) { isReadOnly = true; } // Check whether we have added this column before. Columns are repeated if they are both a PRIMARY_KEY and a FOREIGN_KEY ArchAngel.Providers.Database.Model.Column column = new ArchAngel.Providers.Database.Model.Column( (string)row["COLUMN_NAME"], false, view, (int)row["ORDINAL_POSITION"], Slyce.Common.Utility.StringsAreEqual((string)row["IS_NULLABLE"], "YES", false), (string)row["DATA_TYPE"], row.IsNull("CHARACTER_MAXIMUM_LENGTH") ? 0 : Convert.ToInt32(row["CHARACTER_MAXIMUM_LENGTH"]), (int)row["InPrimaryKey"] == 1, row.IsNull("IsIdentity") ? false : Convert.ToInt32(row["IsIdentity"]) == 1, row.IsNull("COLUMN_DEFAULT") ? "" : (string)row["COLUMN_DEFAULT"], isReadOnly, row.IsNull("IsComputed") ? false : Convert.ToInt32(row["IsComputed"]) == 1, row.IsNull("NUMERIC_PRECISION") ? 0 : Convert.ToInt32(row["NUMERIC_PRECISION"]), row.IsNull("NUMERIC_SCALE") ? 0 : Convert.ToInt32(row["NUMERIC_SCALE"])); view.AddColumn(column); } //smoColumns.Sort(new SortComparer<Microsoft.SqlServer.Management.Smo.Column>("ID", System.ComponentModel.ListSortDirection.Ascending)); //foreach (Microsoft.SqlServer.Management.Smo.Column smoColumn in smoColumns) //{ // if (UnsupportedDataTypes.ToLower().IndexOf("'" + smoColumn.DataType.Name.ToLower() + "'") >= 0) // { // continue; // } // Model.Column column = new Model.Column(smoColumn.Name, Script.GetSingular(smoColumn.Name), false, smoColumn.Name, view, ordinalPosition, smoColumn.Nullable, smoColumn.DataType.Name, smoColumn.DataType.MaximumLength, // false, smoColumn.Identity, smoColumn.Default, true); // view.AddColumn(column); // ordinalPosition++; //} return view; }
private Model.View GetNewView(string viewName) { ArchAngel.Interfaces.ProjectHelper.RaiseObjectBeingProcessedEvent(viewName, "View"); //_columns = null; Model.View view = new Model.View(viewName, false); #region Columns DataRow[] columnRows = Columns.Select(string.Format("TABLE_NAME = '{0}'", viewName)); foreach (DataRow columnRow in columnRows) { Column column = new Column( (string)columnRow["COLUMN_NAME"], false, view, (int)columnRow["ORDINAL_POSITION"], Slyce.Common.Utility.StringsAreEqual((string)columnRow["IS_NULLABLE"], "YES", false), (string)columnRow["DATA_TYPE"], columnRow.IsNull("CHARACTER_MAXIMUM_LENGTH") ? 0 : (int)columnRow["CHARACTER_MAXIMUM_LENGTH"], false, columnRow.IsNull("IsIdentity") ? false : (int)columnRow["IsIdentity"] == 1, columnRow.IsNull("COLUMN_DEFAULT") ? "" : (string)columnRow["COLUMN_DEFAULT"], columnRow.IsNull("IsComputed") ? false : (int)columnRow["IsComputed"] == 1); if (IsSupported(column)) { view.AddColumn(column); } } #endregion return view; }
private Model.View GetNewView(string viewName) { ArchAngel.Interfaces.Events.RaiseObjectBeingProcessedEvent(viewName, "View"); //_dtColumns = null; Model.View view = new Model.View(viewName, false); // Columns DataRow[] columnRows = DtColumns.Select(string.Format("TABLE_NAME = '{0}'", viewName)); foreach (DataRow row in columnRows) { bool isReadOnly = false; if (!row.IsNull("IsIdentity") && (int)row["IsIdentity"] == 1) { isReadOnly = true; } else if (!row.IsNull("IsComputed") && (int)row["IsComputed"] == 1) { isReadOnly = true; } else if (Slyce.Common.Utility.StringsAreEqual((string)row["DATA_TYPE"], "timestamp", false)) { isReadOnly = true; } // Check whether we have added this column before. Columns are repeated if they are both a PRIMARY_KEY and a FOREIGN_KEY ArchAngel.Providers.Database.Model.Column column = new ArchAngel.Providers.Database.Model.Column( (string)row["COLUMN_NAME"], false, view, (int)row["ORDINAL_POSITION"], Slyce.Common.Utility.StringsAreEqual((string)row["IS_NULLABLE"], "YES", false), (string)row["DATA_TYPE"], row.IsNull("CHARACTER_MAXIMUM_LENGTH") ? 0 : Convert.ToInt32(row["CHARACTER_MAXIMUM_LENGTH"]), (int)row["InPrimaryKey"] == 1, row.IsNull("IsIdentity") ? false : Convert.ToInt32(row["IsIdentity"]) == 1, row.IsNull("COLUMN_DEFAULT") ? "" : (string)row["COLUMN_DEFAULT"], isReadOnly, row.IsNull("IsComputed") ? false : Convert.ToInt32(row["IsComputed"]) == 1, row.IsNull("NUMERIC_PRECISION") ? 0 : Convert.ToInt32(row["NUMERIC_PRECISION"]), row.IsNull("NUMERIC_SCALE") ? 0 : Convert.ToInt32(row["NUMERIC_SCALE"])); view.AddColumn(column); } //smoColumns.Sort(new SortComparer<Microsoft.SqlServer.Management.Smo.Column>("ID", System.ComponentModel.ListSortDirection.Ascending)); //foreach (Microsoft.SqlServer.Management.Smo.Column smoColumn in smoColumns) //{ // if (UnsupportedDataTypes.ToLower().IndexOf("'" + smoColumn.DataType.Name.ToLower() + "'") >= 0) // { // continue; // } // Model.Column column = new Model.Column(smoColumn.Name, Script.GetSingular(smoColumn.Name), false, smoColumn.Name, view, ordinalPosition, smoColumn.Nullable, smoColumn.DataType.Name, smoColumn.DataType.MaximumLength, // false, smoColumn.Identity, smoColumn.Default, true); // view.AddColumn(column); // ordinalPosition++; //} return(view); }
private Model.View GetNewView(string viewName) { Interfaces.Events.RaiseObjectBeingProcessedEvent(viewName, "View"); //_columns = null; Model.View view = new Model.View(viewName, false); #region Columns DataRow[] columnRows = Columns.Select(string.Format("TABLE_NAME = '{0}'", viewName)); foreach (DataRow columnRow in columnRows) { bool isReadOnly = false; if (!columnRow.IsNull("IsIdentity") && (int)columnRow["IsIdentity"] == 1) { isReadOnly = true; } else if (!columnRow.IsNull("IsComputed") && (int)columnRow["IsComputed"] == 1) { isReadOnly = true; } else if (Slyce.Common.Utility.StringsAreEqual((string)columnRow["DATA_TYPE"], "timestamp", false)) { isReadOnly = true; } Column column = new Column( (string)columnRow["COLUMN_NAME"], false, view, (int)columnRow["ORDINAL_POSITION"], Slyce.Common.Utility.StringsAreEqual((string)columnRow["IS_NULLABLE"], "YES", false), (string)columnRow["DATA_TYPE"], columnRow.IsNull("CHARACTER_MAXIMUM_LENGTH") ? 0 : Convert.ToInt32(columnRow["CHARACTER_MAXIMUM_LENGTH"]), false, columnRow.IsNull("IsIdentity") ? false : Convert.ToInt32(columnRow["IsIdentity"]) == 1, columnRow.IsNull("COLUMN_DEFAULT") ? "" : (string)columnRow["COLUMN_DEFAULT"], isReadOnly, columnRow.IsNull("IsComputed") ? false : Convert.ToInt32(columnRow["IsComputed"]) == 1, columnRow.IsNull("NUMERIC_PRECISION") ? 0 : Convert.ToInt32(columnRow["NUMERIC_PRECISION"]), columnRow.IsNull("NUMERIC_SCALE") ? 0 : Convert.ToInt32(columnRow["NUMERIC_SCALE"])); if (IsSupported(column)) { view.AddColumn(column); } } #endregion return view; }