// From my form
BindingSource bs = new BindingSource();
private void fillStudentGrid()
{
bs.DataSource = Admin.GetStudents();
dgViewStudents.DataSource = bs;
}
// From the Admin class
public static List<Student> GetStudents()
{
DojoDBDataContext conn = new DojoDBDataContext();
var query =
(from s in conn.Students
select new Student
{
ID = s.ID,
FirstName = s.FirstName,
LastName = s.LastName,
Belt = s.Belt
}).ToList();
return query;
}
I'm trying to fill a datagridview control in Winforms, and I only want a few of the values. The code compiles, but throws a runtime error:
Explicit construction of entity type 'DojoManagement.Student' in query is not allowed.
Is there a way to get it working in this manner?