本文整理汇总了C#中FieldType.Any方法的典型用法代码示例。如果您正苦于以下问题:C# FieldType.Any方法的具体用法?C# FieldType.Any怎么用?C# FieldType.Any使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FieldType
的用法示例。
在下文中一共展示了FieldType.Any方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseType
protected virtual String ParseType(FieldType type) {
List<String> parsed = new List<String>();
Length length = type.FirstOrDefault(attribute => attribute is Length) as Length;
if (type is StringType) {
parsed.Add(String.Format("VARCHAR({0})", length == null ? 255 : length.Value));
}
else if (type is IntegerType) {
parsed.Add("INTEGER");
}
else if (type is DateTimeType) {
parsed.Add("DATETIME");
}
// Enforce NOT NULL and inline primary key when AutoIncrement is used.
if (type.Any(attribute => attribute is AutoIncrement) == true) {
parsed.Add("PRIMARY KEY AUTOINCREMENT NOT NULL");
}
else if (type.Any(attribute => attribute is Nullable) == false) {
parsed.Add("NOT NULL");
}
return String.Join(" ", parsed);
}
示例2: ParseType
protected virtual String ParseType(FieldType type) {
List<String> parsed = new List<String>();
Length length = type.FirstOrDefault(attribute => attribute is Length) as Length;
Unsigned unsigned = type.FirstOrDefault(attribute => attribute is Unsigned) as Unsigned;
if (type is StringType) {
parsed.Add(String.Format("VARCHAR({0})", length == null ? 255 : length.Value));
}
else if (type is IntegerType) {
parsed.Add("INT");
if (unsigned != null) {
parsed.Add("UNSIGNED");
}
}
else if (type is DateTimeType) {
parsed.Add("DATETIME");
}
parsed.Add(type.Any(attribute => attribute is Nullable) == true ? "NULL" : "NOT NULL");
if (type.Any(attribute => attribute is AutoIncrement) == true) {
parsed.Add("AUTO_INCREMENT");
}
return String.Join(" ", parsed);
}