diff --git a/src/SqlSharpener/Model/Column.cs b/src/SqlSharpener/Model/Column.cs index d081a88..d80b3ff 100644 --- a/src/SqlSharpener/Model/Column.cs +++ b/src/SqlSharpener/Model/Column.cs @@ -216,7 +216,7 @@ from r in t.Value private void SetProperties(dac.TSqlObject tSqlObject) { - var sqlDataTypeName = tSqlObject.GetReferenced(dac.Column.DataType).ToList().First().Name.Parts.Last(); + var sqlDataTypeName = tSqlObject.GetReferenced(dac.Column.DataType).ToList().FirstOrDefault()?.Name.Parts.Last(); this.DataTypes = DataTypeHelper.Instance.GetMap(TypeFormat.SqlServerDbType, sqlDataTypeName); this.IsIdentity = dac.Column.IsIdentity.GetValue(tSqlObject); this.IsNullable = dac.Column.Nullable.GetValue(tSqlObject); diff --git a/src/SqlSharpener/Model/IHasColumns.cs b/src/SqlSharpener/Model/IHasColumns.cs new file mode 100644 index 0000000..33bae7e --- /dev/null +++ b/src/SqlSharpener/Model/IHasColumns.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SqlSharpener.Model +{ + /// + /// Represents a table or view in the model. + /// + public interface IHasColumns + { + /// + /// Gets the name of the table or view. + /// + /// + /// The name of the table or view. + /// + string Name { get; } + + /// + /// Gets the columns. + /// + /// + /// The columns. + /// + IEnumerable Columns { get; } + } +} diff --git a/src/SqlSharpener/Model/Table.cs b/src/SqlSharpener/Model/Table.cs index 599f00c..a571ae6 100644 --- a/src/SqlSharpener/Model/Table.cs +++ b/src/SqlSharpener/Model/Table.cs @@ -13,7 +13,7 @@ namespace SqlSharpener.Model /// Represents a table in the model. /// [Serializable] - public class Table + public class Table : IHasColumns { /// /// Initializes a new instance of the class. diff --git a/src/SqlSharpener/Model/View.cs b/src/SqlSharpener/Model/View.cs index 056453e..16fafcc 100644 --- a/src/SqlSharpener/Model/View.cs +++ b/src/SqlSharpener/Model/View.cs @@ -12,7 +12,7 @@ namespace SqlSharpener.Model /// Represents a view in the model. /// [Serializable] - public class View + public class View : IHasColumns { /// /// Initializes a new instance of the class. diff --git a/src/SqlSharpener/SqlSharpener.csproj b/src/SqlSharpener/SqlSharpener.csproj index d87187e..945df28 100644 --- a/src/SqlSharpener/SqlSharpener.csproj +++ b/src/SqlSharpener/SqlSharpener.csproj @@ -78,6 +78,7 @@ +