private void ThenColumnShouldBe(string name, DataType dataType, ColumnSize size, Nullable nullable, string defaultExpression, string defaultConstraintName, string description) { ThenColumnShouldBe(name, dataType, defaultExpression, defaultConstraintName, description); var sizeClause = ""; if (size == null) { if (dataType.ToString().Contains("Var")) { Assert.That(_column.Size, Is.Not.Null); Assert.That(_column.Size.GetType(), Is.EqualTo(typeof(CharacterLength))); Assert.That(_column.Size.Value, Is.EqualTo(CharacterLength.Max)); Assert.That(_column.Size.ToString(), Is.EqualTo("(max)")); sizeClause = "(max)"; } else { Assert.That(_column.Size, Is.Null); } } else { Assert.That(_column.Size, Is.Not.Null); Assert.That(_column.Size.Value, Is.EqualTo(size.Value)); Assert.That(_column.Size.ToString(), Is.EqualTo(size.ToString())); sizeClause = size.ToString(); } Assert.That(_column.Nullable, Is.EqualTo(nullable)); var notNullClause = ConvertToNotNullClause(nullable); var sparseClause = ConvertToSparseClause(nullable); var defaultClause = ConvertToDefaultClause(defaultExpression, defaultConstraintName, true); var fileStreamClause = ""; if (_column.FileStream) { // ReSharper disable once StringLiteralTypo fileStreamClause = " filestream"; } var expectedDefinition = $"[{name}] {dataType.ToString().ToLowerInvariant()}{sizeClause}{fileStreamClause}{notNullClause}{defaultClause}{sparseClause}"; Assert.That(_column.GetColumnDefinition(true), Is.EqualTo(expectedDefinition)); }
public override string ToString() { string text = string.Format("{0}, {1}", ColumnName, (ColumnType == null) ? "null" : ColumnType.ToString()); if (ColumnSize != 0) { text += ", " + ColumnSize.ToString(); } return(text); }
private void ThenColumnShouldBe(string name, DataType dataType, ColumnSize size, Identity identity, string description) { ThenColumnShouldBe(name, dataType, null, null as string, description); Assert.That(_column.Size, Is.Not.Null); Assert.That(_column.Size.ToString(), Is.EqualTo(size.ToString())); Assert.That(_column.Identity.Seed, Is.EqualTo(identity.Seed)); Assert.That(_column.Identity.Increment, Is.EqualTo(identity.Increment)); Assert.That(_column.Identity.NotForReplication, Is.EqualTo(identity.NotForReplication)); Assert.That(_column.Identity.ToString(), Is.EqualTo(identity.ToString())); var expectedDefinition = $"[{name}] {dataType.ToString().ToLowerInvariant()}{size} {identity}"; Assert.That(_column.GetColumnDefinition(true), Is.EqualTo(expectedDefinition)); }
private string GetSqlDataType() { // If the column size = 2147483647, set it to a varchar(MAX), else just set it to the size var columnSizeString = ColumnSize.ToString() == 2147483647.ToString() ? "MAX" : ColumnSize.ToString(); string sqlDataType = DataTypeName.ToUpper(); if (DataTypeName.ToUpper().Contains("CHAR")) { sqlDataType = $"{DataTypeName.ToUpper()}({columnSizeString})"; } else if (DataTypeName.ToUpper().Equals("DECIMAL") || DataTypeName.ToUpper().Equals("NUMERIC")) { sqlDataType = $"{DataTypeName.ToUpper()}({NumericPrecision},{NumericScale})"; } return(sqlDataType); }
protected virtual void ProcessOffsetClass(TagHelperOutput output, ColumnSize size, string breakpoint) { if (size == ColumnSize.Undefined) { return; } var classString = "offset" + breakpoint; if (size == ColumnSize._) { classString += "-0"; } else { classString += "-" + size.ToString("D"); } output.Attributes.AddClass(classString); }
protected virtual void ProcessSizeClass(TagHelperContext context, TagHelperOutput output, ColumnSize size, string breakpoint) { if (size == ColumnSize.Undefined) { return; } var classString = "col" + breakpoint; if (size == ColumnSize.Auto) { classString += "-auto"; } else if (size != ColumnSize._) { classString += "-" + size.ToString("D"); } output.Attributes.AddClass(classString); }
/// <summary> /// Get datatype description /// </summary> /// <returns>datatype description</returns> public string GetDataTypeDescription() { return(SqlCreator.GetSQLServerDataType(DataType, ColumnSize.ToString(), NumericPrecision.ToString(), NumericScale.ToString())); }