in
Forums
Blogs
Files
Devexpress.Com
ClientCenter
Support Center
DevExpress Channel

Persist Objects in Multiple Databases

Last post 9/1/2008 1:26 AM by Rollie Claro. 3 replies.
Page 1 of 1 (4 items)
Sort Posts:
Previous Next
  • 8/29/2008 5:43 PM

    • FSharp
    • Not Ranked
    • Joined on 8/29/2008
    • Posts 3

    Persist Objects in Multiple Databases

    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?

  • 8/31/2008 4:00 PM In reply to

    Re: Persist Objects in Multiple Databases

    Hi,

    Sorry but you can hardly mix objects stored in multiple databases.
    For more information about this, please browse in the knowledge base articles searching for "Multiple databases".
    Here is one of the interesting articles about it where you will find a way of doing it, but with limitations.

    Regards,
    Marc Greiner [DX-Squad]
  • 9/1/2008 1:26 AM In reply to

    Re: Persist Objects in Multiple Databases

    Answer

    There is a work around.

    Create a database View that selects tables from the different databases.

    then create a model in XPO mapping it to the database View.

    the idea is to "shape" your data before passing it to your model

    i have done this trick before with XPO. it should work.

     

    thanks

    -rollie claro

     

    develop a software that even a fool can use, and only a fool will use it
  • 9/1/2008 1:26 AM In reply to

    Re: Persist Objects in Multiple Databases

     

    develop a software that even a fool can use, and only a fool will use it
Page 1 of 1 (4 items)
Copyright © 1998-2008 Developer Express Inc.
ALL RIGHTS RESERVED