Ticket T719366
Visible to All Users

Xpo and multiple databases

created 6 years ago

Hello team,

I just wanted to ask you, is it possible to bind multiple databases with the xpo framework?
Currently, we are evaluating a solution for our internal logistic system.

The problem I have is to find a solution for loading and displaying a lot of orders from our SAP B1 datastorage. In addition to that, we have a WMS which delivers package data like quantity, dimensions and internal package numbers.Also, I want to give my colleagues  the possibility to have an overview for all the upcomming orders they might have to complete.

I´ve worked with XPO once before and it was kinda nice to let all the data being loaded async.
Correct me if I´m wrong, my intention is that, if I am querying data async from the database, using the xpo framework, it also reduces the amount of data which needs to be loaded into the view. It´s just like eating the cake piece by piece and not the whole thing at once. for example: If the GridControl has loaded a few rows into the gridView, the user is just requesting more data from the server by scrolling the view. Out of that, we increase the amount of requests to the server but limiting the amount of data we are pulling from the server. Is that correct?

Basically, I need to get data from 3 different databases and parse them into a model, so that the view exactly knows what kind of data needs to be loaded.
Additionally, will it also be working with different types of database engines like MSSQL and MySQL? It wouldn´t be bad if not.

If this is possible, do you have any kind of tutorial I can use for this approach?
Would you provide a sample solution?
Is there some sort of a best practice case to get this done perfectly?
How would you accomplish this task?

I´m really excited for your answer and I thank you in advance.
best regards.

Answers approved by DevExpress Support

created 6 years ago (modified 6 years ago)

Hello Michael,

The Session and UnitOfWork components connect to the database through the IDataLayer interface (implemented in the SimpleDataLayer and ThreadSafeDataLayer classes). It is possible to initialize several IDataLayer instances at the application startup and use them to create Sessions and UnitOfWorks.

C#
public static IDataLayer DB1 { get; private set; } public static IDataLayer DB2 { get; private set; } // .. XPDictionary dict1 = new ReflectionDictionary(); dict1.CollectClassInfos(typeof(Class1), typeof(Class2), ...); IDataStore prov1 = XpoDefault.GetConnectionProvider(connectionString1, AutoCreateOption.None); DB1 = new SimpleDataLayer(dict1, prov1); XPDictionary dict2 = new ReflectionDictionary(); dict2.CollectClassInfos(typeof(Class3), typeof(Class4), ...); IDataStore prov2 = XpoDefault.GetConnectionProvider(connectionString2, AutoCreateOption.None); DB2 = new SimpleDataLayer(dict2, prov2); // .. Session session1 = new Session(DB1); Session session2 = new Session(DB2);

However, this approach does not allow mixing data stored in different databases. It will be necessary to load data from each database separately and create a mixed collection on the client side.

>> Correct me if I´m wrong, my intention is that, if I am querying data async from the database, using the xpo framework, it also reduces the amount of data which needs to be loaded into the view. It´s just like eating the cake piece by piece and not the whole thing at once. for example: If the GridControl has loaded a few rows into the gridView, the user is just requesting more data from the server by scrolling the view. Out of that, we increase the amount of requests to the server but limiting the amount of data we are pulling from the server. Is that correct?

This is not an XPO feature. The partial data loading is implemented in GridControl (Large Data Sources: Server and Instant Feedback Modes). Server Mode data sources do not allow you to mix data on the client side. If partial data loading is a strict requirement, it is easier to implement it manually. For example, show the "Next Page", "Prev Page" buttons to a user and load objects using the XPCollection component. XPCollection provides special properties for partial data loading: SkipReturnedObjectsTopReturnedObjects.

>> Additionally, will it also be working with different types of database engines like MSSQL and MySQL? It wouldn´t be bad if not.

The approaches described above are database-agnostic. You can connect different Session instances to different databases.

    Comments (2)

      Thank you Uriah for your quick response,

      This answer clearifies a lot of questions to me.
      In my case, I have a mysql datasource which contains every parcel information and a mssql database which contains every order in our erp system.

      Luckily though, I don´t need to mix data that way. I can have multiple gridControls with independent objects. But if I want to highlight every upcomming order, I need to filter each order against my parcel list to exclude each order which has been inserted in the mysql database.
      I will play along with it and use the input above. Also I am going to mark this answer as a solution because it already helps me a lot.

      Thank you for your patience.

      DevExpress Support Team 6 years ago

        You are welcome, Michael!

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.