Extensibility Notes
Restrictions on Collection Semantics
The mapped storage, Pipeline Adapter, and XML serialization support in the Orders system will not work with custom collections that implement dictionary collection semantics. Any collection’s GetEnumerator method must return a list-type enumerator instead of an IDictionaryEnumerator.
PurchaseOrder and Deserialization Constructors
The only extendable Orders class that does not require a deserialization constructor is PurchaseOrder—it is the root class for storage through the mapped storage system and is not saved through serialization to the same table to which the Basket and OrderTemplate classes are saved. The different storage mechanisms serve different purposes. Baskets and OrderTemplates are saved and loaded often as a customer updates an order at a site; PurchaseOrders are created less often, when a user completes an order. Therefore Basket and OrderTemplate operations need higher performance, and give up some flexibility (for example, saving to multiple tables) that is present in the slower but full-featured storage mapping system used with PurchaseOrder.
Mapping Complex Container Relationships
The samples provided with the CS2007 do not cover mapping more complex container relationships among classes. The following are several rules that you must follow in order for relationships to work with the Orders storage mapping system:
The mapping system allows two classes (for example, A and B) to participate in either of the following relationships, but not both; attempting to create a mapping file that describes both relationships will result in unknown behavior.
A is contained by B through a collection class.
An inheritance model where A is the base class and B is the inherited class and one or both classes are mapped.
Multiple-parent container relationships are not allowed, creating such a relationship results in unpredictable behavior. For example, consider a case where there are classes A, B, and C. An invalid scenario results if B contains a collection of C, and A contains both a collection of B and a collection of C, such that C has two parent containing classes.
A collection relationship cannot be created mapping collections of the same type to different tables from the same class. An example of this is the base Orders class LineItem and its two collection members LineItem.OrderLevelDiscountsApplied and LineItem.ItemLevelDiscountsApplied, each of which contain a set of DiscountApplicationRecord instances. There is no way to map members of each of these collections to different tables; there is only one mapping allowed from the child class DiscountApplicationRecord to a set of tables, independent of parent collection instances to which they might belong.
Requiring Setters on Mapped Properties
In the CS2007, it is a requirement that any properties in extended Orders classes that are to be mapped to storage must have both a getter and a setter. The setter is required to restore data from the mapped storage system into a class instance.