private Field GetField(PropertyInfo property) { Type pt = property.PropertyType; if (pt.IsNullable()) { pt = pt.GetNonNullable(); } if (pt.IsArray) { pt = pt.GetElementType(); } IDataTypeHandler handler = DataTypeFactory.Match(pt); if (handler == null) { return(null); } ParquetColumnAttribute columnAttr = property.GetCustomAttribute <ParquetColumnAttribute>(); string name = columnAttr?.Name ?? property.Name; DataType type = handler.DataType; var r = new DataField(name, property.PropertyType //use CLR type here as DF constructor will figure out nullability and other parameters ); r.ClrPropName = property.Name; return(r); }
private Field GetField(PropertyInfo property) { Type pt = property.PropertyType; if (pt.IsNullable()) { pt = pt.GetNonNullable(); } if (pt.IsArray) { pt = pt.GetElementType(); } IDataTypeHandler handler = DataTypeFactory.Match(pt); if (handler == null) { return(null); } ParquetColumnAttribute columnAttr = property.GetCustomAttribute <ParquetColumnAttribute>(); string name = columnAttr?.Name ?? property.Name; DataType type = handler.DataType; var r = new DataField(name, property.PropertyType //use CLR type here as DF constructor will figure out nullability and other parameters ); if (columnAttr != null) { if (handler.ClrType == typeof(TimeSpan)) { r = new TimeSpanDataField(r.Name, columnAttr.TimeSpanFormat, r.HasNulls, r.IsArray); } if (handler.ClrType == typeof(DateTime) || handler.ClrType == typeof(DateTimeOffset)) { r = new DateTimeDataField(r.Name, columnAttr.DateTimeFormat, r.HasNulls, r.IsArray); } if (handler.ClrType == typeof(decimal)) { r = new DecimalDataField(r.Name, columnAttr.DecimalPrecision, columnAttr.DecimalScale, columnAttr.DecimalForceByteArrayEncoding, r.HasNulls, r.IsArray); } } r.ClrPropName = property.Name; return(r); }