private string GetSQLiteType(DocumentColumnMetadata columnMetadata) { var columnType = columnMetadata.GetType(); var sqlType = columnType == typeof(double) ? "REAL" : columnType == typeof(int) ? "INT" : columnType == typeof(bool) ? "INT" : "TEXT"; return(columnMetadata.IsNullable ? sqlType : string.Format("{0} NOT NULL", sqlType)); }
private string FormatField(DocumentMetadata metadata, DocumentColumnMetadata columnMetadata, string value) { if (columnMetadata.IsNullable && string.IsNullOrEmpty(value)) { return(value); } var converter = default(Func <string, DocumentMetadata, DocumentColumnMetadata, string>); var fieldType = columnMetadata.GetType(); if (!this.typeConverters.Any(c => c.Key == fieldType)) { fieldType = typeof(string); } if (!this.typeConverters.TryGetValue(fieldType, out converter)) { throw new FieldFormatException(string.Format(Resources.CsvDocumentReader_CantConvertFieldValue, value, columnMetadata.Type, metadata.DocumentName)); } return(converter(value, metadata, columnMetadata)); }