I am getting an error message with my dapper code below. Any ideas? Thanks!
Error 5 Cannot implicitly convert type 'Data.EmailAddresses' to 'System.Collections.Generic.List<Data.EmailAddresses>
1. Data coming from sql query
StudentId Gender EmailAddress
123456 Female maryjoe@gmail.com
123456 Female mary.joe@mycollege.edu
123456 Female mj@hotmail.com
2. Classes
public class Student
{
public string StudentId { get; set; }
public string Gender { get; set; }
public List<EmailAddresses> emailAddresses { get; set; }
}
public class EmailAddresses
{
public string EmailAddress { get; set; }
}
3. Dapper code I am trying to implement
public List<Student> GetStudentData()
{
List<Student> dataStudent;
using (IDbConnection connection = RepositoryHelper.OpenConnection())
{
dataStudent = connection.Query<Student, EmailAddresses, Student>("mystoredprocedure",
(c, cc) =>
{
c.emailAddresses = cc;
return c;
}, splitOn: "EmailAddress").ToList();
}
return dataStudent;
}