I want to show the attribute of a relation in a DataGridView. I use LINQ to SQL to do the mapping and have the following classes:
class Computer
{
public string Name;
public User User;
}
class User
{
public string Name;
}
I use a DataGridView to show some rows of the Computer
entity and also want to have one column to show the name of the user associated with this computer.
I've created an object data source of the Computer
class. I've set the DataSource
property of my BindingSource to this data source and linked my DataGridView with this BindingSource. I've added a column to my DataGridView and set the DataPropertyName
property to //User.Name//, but this does not work. What is a good way to do this?
I've already thought about creating an additional class which inherits from Computer
and has an additional string property which represents the name of the user; but I want to avoid this solution.