SBarnes wrote:When building custom Collection Item object or Business Logic object how and when do the Delete, Change and Insert flags need to be set?
I fully understand how these work in the iSave scenario.
I realize that in having properties you should call NotifyPropertyChanged and this will set the change flag and creating a new object or clearing one should turn on the insert flag but what about the Read function?
Also with a collection item it doesn't appear that it sets the flags on the collection itself, should it?
What I am trying to achieve is say you have a maintenance form that has a business login object that has a property that is a a Jiwa Collection similar to the the scenario of a sales order with lines in other words a header object and a collection of lines how to best control the save, cancel and delete buttons on the form as I want to have a SetButtons function that will be have appropriately using the Business Logic object that the form is using and looking at the flags?
We handle all that for you for collections, so you should never need to set them.
The only conscious effort you need to make are 2 things, 1. - as you already stated - invoke the NotifyPropertyChanged method in property setters and that will set the ChangeFlag for you.
The Add method of the collection will set the InsertFlag - but only if the Reading flag of the collection is False (which is the 2nd thing you need to do - you should be setting the Reading flag of the collection to true inside the Read method of the collection, and then back to what it was before you set it to true in a finally of the Read method.
Remove method of the collection will set the DeleteFlag for you - but only if the InsertFlag is currently false (we don't want a save to do anything in that scenario).
If your business logic object has a property which is a JiwaCollection, then you should handle the Added, Removed and Changed events of that collection in your business logic and invoke the NotifyPropertyChanged method - that will set the ChangeFlag of the business logic. To prevent this being set when reading, do just as I instructed for the collection - in the Read method, set IsReading to true, then read your collections and set properties, and set the IsReading back to what it was in the finally of the Read method.
You should also use the Clear method of both collections and business logic inside your Read methods and CreateNew.