Model
public class ErrorReport{
public int? Id {get;set;}
public ExceptionReport Exception {get;set;}
public ExceptionReport InnerException {get;set;}
}
public class ExceptionReport{
public string Type {get; set;}
public string Message {get; set;}
}
Database
This is the table i want to query from
ErrorReports
- Id: int
- ExceptionType: varchar
- ExceptionMessage: varchar
- InnerExceptionType: varchar
- InnerExceptionMessage: varchar
The problem
So, what i want to do is querying the database and map the results into my model properties. But this doesn't work:
using (var con = ConnectionFactory.CreateConnection(_connectionString))
{
IEnumerable<ErrorReport> reports = con.Query<ErrorReport>("Select * from ErrorReports");
}
I understand that i have to explicitly say which columns map to which property, so, how can i do that?