collection of object inside objects #1517
Unanswered
antonynasrallah
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi Josh
first of all thanks for the library it is great,
My question is about collection inside collection , is there is away to use csv helper to expand the colmns and create dynamic columns as it do in the single object
Ex:-
. this works perfect.
-------------------------but ifwe have 1->N relation how we can do it in writing ( if we know N is limited by 2 or 3 )
`the more we can do it in generic way , will be easier as we have alot of classes use them ,
writter class
public byte[] GetCSVFile(T[] items)
{
using (var memoryStream = new MemoryStream())
{
using (var streamWriter = new StreamWriter(memoryStream))
using (var csvWriter = new CsvWriter(streamWriter, CultureInfo.InvariantCulture))
{
// csvWriter.Configuration.RegisterClassMap();
csvWriter.Configuration.AutoMap();
csvWriter.Configuration.ReferenceHeaderPrefix = (membertype, memberName) => $"{memberName}";
csvWriter.WriteRecords(items);
}
return memoryStream.ToArray();
}
}
Thanks Again
Antony
Beta Was this translation helpful? Give feedback.
All reactions