I am using Dapper to map objects coming out of a SQL Server database to C# classes. One of the stored procedures I need to pull results from can have a variable number of columns depending on the context. This result set will always have a primary key column, and then 0 to 30 additional columns that will all be of the same data type.
The result set columns are basically like this:
CustomerID | Email1 | Email2 | Email3 | ...
Where the number of Email* columns depends on the highest number of email addresses on file for a customer in the query.
The natural way to capture this in C# is with a class like this:
class Customer {
int ID { get; set; }
string[] EmailAddresses { get; set; }
}
Is there a way to use Dapper to map my result set to an object like this?