I'm attempting to return a List of entities using dapper and a MySQL Stored Procedure, but it returns the data with null values for some reason. It returns the list of entities, but only displays their Id -- CourseName and HoleLayouts are always null. It's a simple query, which is why it is very confusing to me, and it also works for different entities/database tables. I changed the column for course_name to be the type of VARCHAR(255) since originally it was VARCHAR(45) which didn't make a difference. Even with debugging, I can see through the stack trace that the course names are null through the repositories return statement but not their id.
I'll have the code below to try and help further explain.
Entity
public class Course
{
public int Id { get; set; }
public string CourseName { get; set; } = null!;
public ICollection<HoleLayout> HoleLayouts { get; set; } = null!;
}
Repository/Query
public async Task<IEnumerable<Course>> FindAllAsync()
{
using var connection = _dataAccessor.CreateConnection();
var courses = await connection.QueryAsync<Course>("GetAllCourses",
commandType: CommandType.StoredProcedure);
return courses;
}
Stored Procedure
create
definer = root@localhost procedure GetAllCourses()
BEGIN
SELECT * FROM courses;
END;
JSON Response
[
{
"id": 1,
"courseName": null,
"holeLayouts": null
}
]
Course schema

.ToList();is needed,var courses = await connection.QueryAsync<Course>("GetAllCourses", commandType: CommandType.StoredProcedure).ToList();stackoverflow.com/a/41698348courses? does it have acourseNamecolumn? note: Dapper can't help you withholdLayouts- that's complex structured data, which Dapper doesn't do. Also: what data provider is this (in case it is relevant - I simply don't recognize that SQL variant) ? edit: I would expectcourse_nameto work, but again: seeing the schema would help*in SQL; if that SP is meant to return theId,CourseNameand something else: say that explicitly - this avoids problems where "safe" changes to the schema (like adding a column) change the way your application works; it also avoids fetching unnecessary data - perhaps a few large text or image columns - over the network, just to be ignored*, would using DTOs fix that issue?*; on the same; weird, I would have expected that to work - maybe try adding an underscore in the C#, just to see if that helps?