My company is writing an application that archives reports generated by another application. We keep data in two databases:
- A 'Reports' database, containing information such as a reports group, subgroup, group permissions, and information on who has looked at a report.
- A 'ReportData' database, containing just a single table holding the actual content of each archived report.
This design is deliberate. The 'ReportData' database grows by a couple 10s of GB every few months due to the huge quantity of data archived everyday; when the database gets too large to fit on disk, our users can simply back the database up to a tape drive, click a button, and a fresh 'ReportData' database will be generated and be ready to fill up with tons of data.
Both databases are (usually) on the same server.
I'm initializing XPO like this:
string conn = ConfigurationManager.ConnectionStrings["ReportConnectionString"].ConnectionString;
DevExpress.Xpo.Metadata.XPDictionary dict = new DevExpress.Xpo.Metadata.ReflectionDictionary();
// Initialize the XPO dictionary.
dict.GetDataStoreSchema(Assembly.GetExecutingAssembly());
DevExpress.Xpo.XpoDefault.Session = null;
DevExpress.Xpo.DB.IDataStore store = DevExpress.Xpo.XpoDefault.GetConnectionProvider(conn, DevExpress.Xpo.DB.AutoCreateOption.SchemaAlreadyExists);
DevExpress.Xpo.XpoDefault.DataLayer = new DevExpress.Xpo.ThreadSafeDataLayer(dict, store);
The ReportConnectionString points to the 'Reports' databases.
I've created all of my persistent classes, however I don't see any obvious way to map my Report class to the 'ReportData' database. I attempted to create an attribute like this:
[Persistent("ReportData.dbo.Reports")]
public class Report : XPLiteObject
However, when XPO executes a query, I get an error that the table 'ReportData.dbo_Reports_62A1E86D' does not exist -- this doesn't make any sense because I did not type that table name in the first place.
I think I'm missing something obvious, but how do I map classes to tables stored in multiple databases?