The .Query<TModel>() method maps column names to property names on the model, but this means that if a column name contains characters that can't be in a c# property (e.g. % or (), we can't use it.
It would be good if an attribute called something like ColumnNameAttribute were added to the project so we could use it to annotate properties in the model, which would allow us to map columns with unusual characters easily.
A model would look something like this:
public class RowModel
{
[ColumnName("Coverage %")]
public string Coverage {get; set; }
// etc.
}
I imagine the code would use the value in this attribute, falling back to the property name if the attribute isn't present. It'd be a small change here:
|
foreach (var propertyName in RowMaterializer.GetSettableProperties(typeof(T)) |
|
.Select(property => property.Name)) |
I've seen this pattern used in other data mapping-type libraries, and it works well, e.g. https://github.com/hughbe/excel-mapper#attribute-based-mapping
The
.Query<TModel>()method maps column names to property names on the model, but this means that if a column name contains characters that can't be in a c# property (e.g.%or(), we can't use it.It would be good if an attribute called something like
ColumnNameAttributewere added to the project so we could use it to annotate properties in the model, which would allow us to map columns with unusual characters easily.A model would look something like this:
I imagine the code would use the value in this attribute, falling back to the property name if the attribute isn't present. It'd be a small change here:
DbfDataReader/src/DbfDataReader/Query/DbfQuery.cs
Lines 465 to 466 in 4f6ac3e
I've seen this pattern used in other data mapping-type libraries, and it works well, e.g. https://github.com/hughbe/excel-mapper#attribute-based-mapping