This is a migrated thread and some comments may be shown as answers.

Two way binding with IQueryable, MVVM and EF not refreshing RadGridView control

1 Answer 245 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Eduardo
Top achievements
Rank 1
Eduardo asked on 25 Jun 2016, 12:16 PM
Hello,

Due to project requirements for a big customer I need to bind entity framework 6 dbcontext directly to telerik controls, in this case to a radgridview control, so i need to use IQueryable instead of ObservableCollection also to perform filtering, sorting and so on.  

The point is that when I add, delete a customer from dbcontext, the radgridview don't refresh showing changes.  Also when I perform this operations directly in database, after refreshing dbcontext the radgridview not showing changes.

I tried to implement INotifyPropertyChanged and INotifyCollectionChanged in my view model but without success.  

Also I want to point out that due to mvvm pattern design I can't have code in mainwindow.xaml.cs.

Please, anyone can provide me a full example of how to achieve this? 

Thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 29 Jun 2016, 11:14 AM
Hello Eduardo,

I'm afraid that RadGridView is only responsible for responding to changes in the underlying data context and only if the bound objects implement the INotifyPropertyChanged interface. You should design your application in such way that it responds to changes in your DbContext which, by default, in no way notifies on its change.

Here are a few articles I found, discussing similar issues:
Update databound datasource in c# when data in database changes
Managing DbContext in WPF MVVM application
How do I Refresh DbContext

I hope you find these helpful.

Regards,
Dilyan Traykov
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
GridView
Asked by
Eduardo
Top achievements
Rank 1
Answers by
Dilyan Traykov
Telerik team
Share this question
or