Search code examples
sqlentity-frameworkforeign-keyssyncfusiondevart

EF - Mapping foreign key between DevArt EntityDeveloper & Syncfusion WinForm grid


I need some help to understand the best way to represent datas from SQL DB to SyncFusion grid control.

The Animal table contains foreign keys for eye color, coat color...

I can add the ObjectSet from ObjectContext generated by DevArt as DataSource for SyncFusion sfDataGrid. As we can see on the picture, we see the foreign keys.

SQL Table content

If I want to have the {rec.Coat.Name} instead of {rec.CoatId} displayed, I have to use UnboundColumn (enter link description here). But using this way cause some troubles : SyncFusion component cannot sort UnboundColumn. From the editor, there's no plan to implement it.

So, what's the good way using Entity Framework to convert datas (and convert foreign keys) from SQL table to the good DataSource for Winform control ?

Thanks for help.

Vincent


Solution

  • Try using Join in your LINQ query to replace rec.CoatId with rec.Coat.Name in the result set: https://learn.microsoft.com/en-us/ef/core/querying/complex-query-operators .