I use Filehelpers to import my database from files. Now I'm working on the reverse process, and I'm having problems with how to create records from my data objects.
All the examples that I can find are derived from the file -> table -> file. I use generic interfaces to convert. I use this code for inbound conversion:
public interface IConvertCSVRecordToType<T> where T : SimpleBase
{
T ConvertCSVRecordToType();
}
and would like to use something like this for outgoing:
public interface IConvertTypeToCSVRecord<T> where T : SimpleBase, new()
{
void ConvertTypeToCSVRecord(T type);
}
I use this class to represent CSV records:
[DelimitedRecord(";"), IgnoreEmptyLines]
public class CSVRecordFormat : IConvertCSVRecordToType<Material>,
IConvertTypeToCSVRecord<Material>
I came across TransformToRecordAttribute in the Filehelpers documentation
Class TransformToRecordAttribute
With this attribute, you can mark the method in RecordClass, which is responsibly convert it to specified.
- , , , ?