Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/SqlSharpener/Model/Column.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>(tSqlObject);
this.IsNullable = dac.Column.Nullable.GetValue<bool>(tSqlObject);
Expand Down
30 changes: 30 additions & 0 deletions src/SqlSharpener/Model/IHasColumns.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SqlSharpener.Model
{
/// <summary>
/// Represents a table or view in the model.
/// </summary>
public interface IHasColumns
{
/// <summary>
/// Gets the name of the table or view.
/// </summary>
/// <value>
/// The name of the table or view.
/// </value>
string Name { get; }

/// <summary>
/// Gets the columns.
/// </summary>
/// <value>
/// The columns.
/// </value>
IEnumerable<Column> Columns { get; }
}
}
2 changes: 1 addition & 1 deletion src/SqlSharpener/Model/Table.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace SqlSharpener.Model
/// Represents a table in the model.
/// </summary>
[Serializable]
public class Table
public class Table : IHasColumns
{
/// <summary>
/// Initializes a new instance of the <see cref="Table"/> class.
Expand Down
2 changes: 1 addition & 1 deletion src/SqlSharpener/Model/View.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace SqlSharpener.Model
/// Represents a view in the model.
/// </summary>
[Serializable]
public class View
public class View : IHasColumns
{
/// <summary>
/// Initializes a new instance of the <see cref="View"/> class.
Expand Down
1 change: 1 addition & 0 deletions src/SqlSharpener/SqlSharpener.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
<Compile Include="DataType.cs" />
<Compile Include="ForeignKeyConstraintVisitor.cs" />
<Compile Include="Model\Column.cs" />
<Compile Include="Model\IHasColumns.cs" />
<Compile Include="Model\RelationshipIdentifier.cs" />
<Compile Include="Model\Table.cs" />
<Compile Include="Model\View.cs" />
Expand Down