private static EntityField ToEntityField(SqlSchemaInfo.FieldInfo fieldInfo, int prefixLength) { string flags; if (fieldInfo.IsIdentity) { flags = "Identity"; } else if (fieldInfo.IsPrimaryKey) { flags = "PrimaryKey"; } else if (fieldInfo.DataType == "timestamp" || fieldInfo.DataType == "rowversion") { flags = "Insertable(false), Updatable(false), NotNull"; } else if (!fieldInfo.IsNullable) { flags = "NotNull"; } else { flags = null; } string dataType; var fieldType = SqlSchemaInfo.SqlTypeNameToFieldType(fieldInfo.DataType, fieldInfo.Size, out dataType); dataType = dataType ?? fieldType; return(new EntityField { FieldType = fieldType, DataType = dataType, IsValueType = fieldType != "String" && fieldType != "Stream" && fieldType != "ByteArray", TSType = FieldTypeToTS(fieldType), Ident = GenerateVariableName(fieldInfo.FieldName.Substring(prefixLength)), Title = Inflector.Inflector.Titleize(fieldInfo.FieldName.Substring(prefixLength)), Flags = flags, Name = fieldInfo.FieldName, Size = fieldInfo.Size == 0 ? (Int32?)null : fieldInfo.Size, Scale = fieldInfo.Scale }); }
private static EntityField ToEntityField(ISqlDialect dialect, SqlSchemaInfo.FieldInfo fieldInfo, int prefixLength) { var dataTypeInfo = dialect.SqlTypeNameToDataType(fieldInfo.DataType, fieldInfo.Size); string specificDataType = dataTypeInfo.SpecificDataType ?? dataTypeInfo.DataType; string flags; if (fieldInfo.IsIdentity) { flags = "Identity"; } else if (fieldInfo.IsPrimaryKey) { flags = "PrimaryKey"; } else if (dataTypeInfo.IsNonUpdatable) { flags = "Insertable(false), Updatable(false), NotNull"; } else if (!fieldInfo.IsNullable) { flags = "NotNull"; } else { flags = null; } return(new EntityField { FieldType = dataTypeInfo.DataType, DataType = specificDataType, IsValueType = dataTypeInfo.DataType != "String" && dataTypeInfo.DataType != "Stream" && dataTypeInfo.DataType != "ByteArray", TSType = FieldTypeToTS(dataTypeInfo.DataType), Ident = GenerateVariableName(fieldInfo.FieldName.Substring(prefixLength)), Title = Inflector.Inflector.Titleize(fieldInfo.FieldName.Substring(prefixLength)), Flags = flags, Name = fieldInfo.FieldName, Size = fieldInfo.Size == 0 ? (Int32?)null : fieldInfo.Size, Scale = fieldInfo.Scale }); }