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

All entities are reloaded from DB after SaveChanges called

3 Answers 55 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Pawel
Top achievements
Rank 1
Pawel asked on 21 Apr 2015, 03:09 PM

Hello,

 I got simple entities list connected to RadGridView (With RadObservableCollection).

Then I change some field in RadGridView and do SaveChanges() - all changes are reflected in DB.

 Now when I scroll, filter, sort or do anything in code with any entity all entities are reloaded from DB.

 I suppose that saving any 1 item to DB changes state of all other items in that entity.

How can I avoid reloading? ( I use 2nd level cache already)

3 Answers, 1 is accepted

Sort by
0
Doroteya
Telerik team
answered on 24 Apr 2015, 01:33 PM
Hi Pawel,

Thank you for contacting us.

In general, the behaviour you are experiencing is expected in such scenario. It ensures that the UI always displays up-to-date values from the database. Perhaps you could share a little bit more details about the design needs that require you to rely on not-updated in-memory objects.

I am looking forward to hearing from you.


Regards,
Doroteya
Telerik
 
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
 
0
Pawel
Top achievements
Rank 1
answered on 26 Apr 2015, 10:32 AM

Hi Doroteya,

 I'm loading about 900 rows of data for fast searching in gridview, so reloading all of them one by one with DB is freezing whole WPF application, and its really not needed at all when I change only 1 row.

 

0
Doroteya
Telerik team
answered on 29 Apr 2015, 08:52 AM
Hello Pawel,

Thank you for getting back to us and for the additional information.

As far as I understand the situation, currently when you do SaveChanges the rows of the grid are reloaded one by one, which I confirm is quite slow.

A much performant approach that allows you display the latest state of the database is to reload the data with just one SELECT statement. if you find this feasible, you can review a sample implementation in our WPF Quick Start Scenario. It consumes plain List<T> collections to hold the binding data and the INotifyPropertyChanged interface for communication with the UI. With this approach, once the changes are committed to the database, the whole collection is retrieved with a single SELECT, and when you apply some filtering, only the relevant data are fetched with just one statement.

I hope this helps. Let us know how the things on your side are. 

Regards,
Doroteya
Telerik
 
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
 
Tags
Development (API, general questions)
Asked by
Pawel
Top achievements
Rank 1
Answers by
Doroteya
Telerik team
Pawel
Top achievements
Rank 1
Share this question
or