This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hallo, I have the following scenario: 1) my app shows read-only list of employees (list has its own unit of work to get data) 2) there is a dialog for employee editing purpose (dialog has its own unit of work) And now - let's imagine end-user opens dialogs, makes changes and finally save changes -> dialog is closed. And now I'd like to refresh changed record on the employees list. But only this one (just changed) record, not the whole list. Is there any uow.Refresh(entity) or uow.Reload(entity) methods? I found some posts related to such scenario, but from year 2009 :-( Does anything changed since then? How to handle with this common scenario? Best regards, Aleksandra |
|
|
There is no Refresh method or equivalent operation as you can get a fresh instance by querying it in a fresh UnitOfWork (or by detaching the existing instance) and then attaching that entity back into another UnitOfWork if required. In terms of what you are trying to achieve with the refreshed list - how are you maintaining the list of employees (e.g. is this a WPF app with a data-bound list?) and how are you notifying on a specific user changing? Could you not just notify of the changed entity and replace the existing entry in the list as that avoids the need to query the database again when the changes are being made in-app.
|
|
|
Hallo, yes this is WPF application + MVVM pattern used I tried this
UnitOfWork is a property of my UsersListDialog - and this uow lives when this dialog lives. And genarally it works But instead of //???????????????????? I should insert the code, which allows inform my GUI control - I mean Grid - that should "rebind" changed entity. And only this one entity - not the whole list. Does LightSpeed entity have any method that can raise change notification? My GUI controls are sesitive for change notification, but how to invoke it on your entity? Regards, Aleksandra |
|
|
Yes you can hook the PropertyChanged event on the entity to receive a callback when a property on the entity is updated, or hook the Saved event to receive a callback when the entity has been persisted which will indicate one or more changes.
|
|
|
I'm attempting to detect changes to the database from an outsource source. So far I've been unsuccessful. Inside my Myfsysserialnumber partial class I have overrode the OnPropertyChanged and set a breakpoint. I then go in and modify the database manually but no happens on the OnPropertyChanged. What am I doing wrong here? I need to create something that actively monitors changes in the db and pulls them in.
|
|
|
OnPropertyChange is triggered when you modify an entity property as part of your application, LightSpeed does not detect any changes made at the database so you are right that you will need something to actively monitor the database for changes if you need that. Are you able to elaborate a bit on your scenario? How are the external modifications being made and is there an option for notification of changes to occur to avoid having to poll the database fairly aggressively?
|
|