Reputation: 1
These are the errors I have now
I have two nested objects that I want to write out to a csv file for later reading. I went through online documentation for CsvHelper library and other posts and tried to write classmap definitions but I am getting below errors:
THe word "Map" does not exist in the current context
The word "References" does not exist in the current context
How can I get rid of these erros? I don't see Map or References in the intellisense. I am unsing csvhelper library, it is installed and I can write normal lines to csv files. So it is working but some parts of the library are not working!?
I tried to code my objects and mapclass exactly as what is described here: https://github.com/JoshClose/CsvHelper/issues/244
here is my code. I have a list containing objects of type "Channel"; each channel object contains a list of sections with type "section". I need to write out all channels and all sections of each channel out to csv file for future reading. Map and references words are highlighted in red with the errors.
public sealed class SectionDefinitionMap : CsvClassMap<Section>
{
public SectionDefinitionMap()
{
Map(m => m.Name).Name("Section.Name");
}
}
public sealed class ChannelDefinitionMap : CsvClassMap<Channel>
{
public ChannelDefinitionMap()
{
Map(m => m.Name).Name("Channel.Name");
References<SectionDefinitionMap>(m => m.Section);
}
}
Upvotes: 0
Views: 2271
Reputation: 1118
CsvClassMap
is renamed to ClassMap
in the newer version of CsvHelper. It is located in the CsvHelper.Configuration
namespace.
Upvotes: 0