Last modified 2 years ago
Composite DataContext
The composite DataContext is a DataContext implementation that enables delegation to multiple underlying DataContext's. It makes it possible to explore and query across different and physical independent datastores, for example databases, spreadsheets, CSV files etc.
Usage
You create a Composite DataContext by invoking one of the static createCompositeDataContext(...) methods in DataContextFactory. There are two methods with this name: One that takes a var-args array and one that takes a collection of DataContexts as the parameter.
//Obtain the underlying datastores
DataContext dc1 = ...;
DataContext dc2 = ...;
DataContext dc3 = ...;
//Now create the composite, which wraps all the other datastores
DataContext compositeDc = DataContextFactory.createCompositeDataContext(dc1, dc2, dc3);
//Now we can explore and query all the underlying datastores using just the single "compositeDc" DataContext!
Neat huh?
