This generates classes that are primarily designed to be used in WPF applications.
<#@ DataStoreCodeGenerator Processor="Semata.CodeGeneratorDirectiveProcessor" #> <# GenerateObjectModelViews("OrderProcessing.ds", "OrderProcessing", "OrderProcessing"); #>
DataStoreView Class
A class will be generated for the DataStore. This will be a view of the DataStore class.
This class will have a property for each ItemType of type ItemObjectViewList<I, V>.
It will have methods to Open and Close the DataStore, with 1 partial method call back: OnInitialize(), which is called after the DaStore is opened
ItemObjectView Class
A class will be generated for each ItemType, and that class will inherit from ItemObjectView<I>. This class is a view of the corresponding ItemObject.
There will be 3 constructors: one that takes an ItemObject; one that takes an ItemObjectView; and a default constructor. The default constructor is supplied mainly for the use of CollectionViews based on ItemObjectViewList<I, V>.
Any AttributeProperty or AssociationProperty of the ItemObject will be exposed as property of the view. Any Association of the ItemObject will be exposed as an ItemObjectViewList<I, V>, where I is the associated ItemObject, and V is the generated view class for that object.
ItemObjectViewList Class
The ItemObjectViewList<I, V> class represents the ItemObjects in an ItemObjectCollection<I> as a IList<V>, such that it can be used as the ItemSource of a ItemsControl
The behaviour of the ItemObjectViewList<I, V> is governed by the constructor's delayRemoves parameter and the WriteOnEndEdit property on the ItemObjectView created by the constructor's itemObjectViewCreator delegate parameter.
If delayRemoves is true a removed ItemObjectView will not appear in the list, but it is only removed in the DataStore when WriteChanges is called. At any time before this call CancelChanges will cancel the remove.
If WriteOnEndEdit is true then a call to IEditableObject.EndEdit will action the changes on the DataStore. If false the changes are only actioned when WriteChanges is called.
So it is usual to see WriteOnEndEdit = true and delayRemoves = false, or WriteOnEndEdit = false and delayRemoves = true
A DataGrid with its ItemSource set as a ItemObjectViewList with the former settings would automatically action the changes on the DataStore as Rows where added, changed, and deleted. If the settings were as the latter then those changes would only be actioned on the DataStore when WriteChanges was called.