public override string ToQuery() { switch (Type) { case DataTypeOperation.From: return(string.Format("create type [{0}].[{1}] from {2}", SchemaName, Name, From)); case DataTypeOperation.Assembly: return(string.Format("create type [{0}].[{1}] external name {2}.[{3}]", SchemaName, Name, AssemblyName, ClassName)); case DataTypeOperation.Table: var columnDefinitionList = new List <string>(); foreach (Column column in AsTable) { columnDefinitionList.Add(column.GetColumnDefinition(false)); } string columnDefinitionClause = string.Join(", ", columnDefinitionList.ToArray()); var tableConstraintClause = string.Join(", ", TableConstraint.ToArray()); columnDefinitionClause = string.Format("({0} {1})", columnDefinitionClause, tableConstraintClause); var query = string.Format("create type [{0}].[{1}] as table {2}", SchemaName, Name, columnDefinitionClause); return(query); default: throw new ArgumentOutOfRangeException(); } }