Hello,
using LLBLGen 4.2, SQLServer, I'm having problems binding subobject properties to a DevExpress grid.
Image I'm having entities Users & Orders, where an Order has a FK UserId, and thus has a User subobject in the generated code.
Now if I want to bind a list of Orders in a DevExpress grid, it should be possible to set a fieldName
to a subobject.
I've tested this using the following code:
In my Viewmodel
public class Viewmodel
{
public class User
{
public string Name { get; set; }
}
public class Order
{
public string Code { get; set; }
public User User { get; set; }
}
public IEnumerable<Order> Orders
{
get
{
User u1 = new User() { Name = "user1" };
User u2 = new User() { Name = "user2" };
return new List<Order>()
{
new Order() {Code = "order1", User = u1},
new Order() {Code = "order2", User = u2},
new Order() {Code = "order3", User = u1},
new Order() {Code = "order4", User = u1},
};
}
}
}
In My View :
<dxg:GridControl AutoGenerateColumns="None" ItemsSource="{Binding Orders}" >
<dxg:GridControl.Columns>
<dxg:GridColumn Header="Code" FieldName="Code" />
<dxg:GridColumn Header="Username" FieldName="User.Name" />
</dxg:GridControl.Columns>
</dxg:GridControl >
This works like a charm, and I get my correct values in the grid. So the DXGrid works.
The moment I use "real" LLBLGen entities, OrderEntity and UserEntity, the field "User.Name" doesn't display a value anymore.
I'm sure everything is fetched correctly, because if I change my View to using a simple listbox to display the usernames, the list is filled correctly :
<ListBox ItemsSource="{Binding Orders}" DisplayMemberPath="User.Name"></ListBox>
So it is actually the combination of the DXGrid and LLBLGen. A bit of searching around brought me on this 10yr old question that seems to be related : https://www.devexpress.com/Support/Center/Question/Details/CB13178
Any idea ?