本文整理汇总了C#中DatabaseSchemaReader.DataSchema.DatabaseColumn.DataTypeDefinition方法的典型用法代码示例。如果您正苦于以下问题:C# DatabaseColumn.DataTypeDefinition方法的具体用法?C# DatabaseColumn.DataTypeDefinition怎么用?C# DatabaseColumn.DataTypeDefinition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DatabaseSchemaReader.DataSchema.DatabaseColumn
的用法示例。
在下文中一共展示了DatabaseColumn.DataTypeDefinition方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestDataTypeDefinitionForInt
public void TestDataTypeDefinitionForInt()
{
//arrange
var column = new DatabaseColumn { DbDataType = "int", DataType = new DataType("int", "int") };
//act
var result = column.DataTypeDefinition();
//assert
Assert.AreEqual("int", result);
}
示例2: TestDataTypeDefinitionForVarChar
public void TestDataTypeDefinitionForVarChar()
{
//arrange
var column = new DatabaseColumn
{
DbDataType = "nvarchar",
DataType = new DataType("nvarchar", "System.String"),
Length = 15
};
//act
var result = column.DataTypeDefinition();
//assert
Assert.AreEqual("nvarchar(15)", result);
}
示例3: TestDataTypeDefinitionForMySqlVarChar
public void TestDataTypeDefinitionForMySqlVarChar()
{
//arrange
var column = new DatabaseColumn
{
DbDataType = "varchar(50)",
//below will be ignored as MySql gives the full native type
DataType = new DataType("VARCHAR", "System.String"),
Length = 50
};
//act
var result = column.DataTypeDefinition();
//assert
Assert.AreEqual("varchar(50)", result);
}
示例4: TestDataTypeDefinitionForDecimal
public void TestDataTypeDefinitionForDecimal()
{
//arrange
var column = new DatabaseColumn
{
DbDataType = "decimal",
DataType = new DataType("decimal", "System.Decimal"),
Precision = 10,
Scale = 2
};
//act
var result = column.DataTypeDefinition();
//assert
Assert.AreEqual("decimal(10,2)", result);
}
示例5: FillColumn
private static void FillColumn(TreeNode tableNode, DatabaseColumn column)
{
var sb = new StringBuilder();
sb.Append(column.Name);
sb.Append(" ");
sb.Append(column.DataTypeDefinition());
if (!column.Nullable)
{
sb.Append(" NOT NULL");
}
if (column.IsPrimaryKey)
{
sb.Append(" PK");
}
if (column.IsAutoNumber)
{
//identity or autonumber
if (column.IdentityDefinition != null)
{
sb.Append(" Identity");
if (column.IdentityDefinition.IsNonTrivialIdentity())
{
sb.Append('(');
sb.Append(column.IdentityDefinition.IdentitySeed);
sb.Append(',');
sb.Append(column.IdentityDefinition.IdentityIncrement);
sb.Append(')');
}
}
else
{
sb.Append(" AutoNumber");
}
}
if (column.IsForeignKey)
{
sb.Append(" FK to " + column.ForeignKeyTableName);
}
var colNode = new TreeNode(sb.ToString());
if (!(column.Table is DatabaseView))
{
colNode.Tag = column;
colNode.ToolTipText = RightClickToScript;
}
tableNode.Nodes.Add(colNode);
}
示例6: TestDataTypeDefinitionForMySqlSmallInt
public void TestDataTypeDefinitionForMySqlSmallInt()
{
//arrange
var column = new DatabaseColumn
{
DbDataType = "smallint(5) unsigned",
//below will be ignored as MySql gives the full native type
DataType = new DataType("SMALLINT", "System.Int16"),
Precision = 5,
Scale = 0
};
//act
var result = column.DataTypeDefinition();
//assert
Assert.AreEqual("smallint(5) unsigned", result);
}