I'm struggling a little bit with this and can't seem to find an answer here. I am using the SautinSoft Document plug-in to create a mail merge in MS Word. The data source is my issue. My data in a DataTable, whereas the function they have coded to pass the data is in an anonymous array:
var dataSource = new[]
{ new { FirstName = "Hector", LastName = "Stupid", Age = "40" },
new { FirstName = "Penelope ", LastName = "Plank", Age = "25" }
};
So, I need to iterate through my DataTable populating the fields into this format with their values.
Then, I execute the Mail Merge thus:
dc.MailMerge.Execute(dataSource);
The question is how? Since the array is being statically populated. I've tried many solutions, passing either the DataTable, converting to a Dictionary, and .ToArray() over Ienumerable, but nothing seems to replicate this format.
Many thanks in advance.
datasource.Select(row => new { FirstName = row.whatever, LastName = row.whateverelse, Age = row.whatever }).ToArray()not working for you?