The xpath query is too complex


I am experimenting with Federated data and am getting the error "The xpath query is too complex".

I am trying to access an external SQL Server database. I wrote a method that I invoke in the "onGet" Server Event of the Part ItemType. Here's what the method looks like:

string szConnectionString = @"Provider=SQLOLEDB;Data Source=MYSQL\Dev; Initial Catalog=PART; User ID=innovator; Password=";


System.Data.OleDb.OleDbConnection myConnection = new System.Data.OleDb.OleDbConnection(szConnectionString);

string sqltext = "select part_nbr,cage,mfr_desc from PART.dbo.part";


System.Data.OleDb.OleDbCommand com = new System.Data.OleDb.OleDbCommand(sqltext);

com.Connection = myConnection;



System.Data.OleDb.OleDbDataReader myDataReader = com.ExecuteReader();

 Item res5 = this.newItem("Part");


res5 = res5.apply();

while (myDataReader.Read())


    Item temp = this.newItem("Part");  

    temp.setProperty("part_nbr", myDataReader.GetString(0));

    temp.setProperty("cage", myDataReader.GetString(1));

    temp.setProperty("ccmfr_desc", myDataReader.GetString(2));




return res5.apply();

In my "Part" ItemType I added 3 Federated properties: part_nbr, cage, ccmfr_desc.

Can anyone shed some light here? Thanks!

  • Hi guacimapr,

    "The xpath query is too complex" is a common error when using "appendItem()". There is a maximum number of items you can append to an item (collection), before this error gets thrown (I forget how high that number was, maybe somewhere around 2000?). You can work around this by looping at most, say, 1500 times, then applying, and then continuing to loop over a now freshly empty collection.

    Regardless, I'd be interested in what you want to achieve with this. It feels like this is not quite how property federation is normally implemented. If you simply want to populate some federated properties on 'Part' by values from a SQL database, an onAfterGet method should be completely fine and no "apply()" would be necessary.

    int thisCount = this.getItemCount();
    for (int i = 0; i < thisCount; i++)
       var currentItem = this.getItemByIndex(i);
       string federatedPropertyValue = GetPropertyValueFromSql(currentItem.getID())
       currentItem.setProperty("federated_property", federatedPropertyValue);

    return this;

    This code assumes that you can get the federated information from the SQL DB from a Part's ID in a custom method called GetPropertyValueFromSql(). Note that you will not 'apply()' the item here, since that would commit the data to the local Aras DB. Since we want item federation, we simply add the property to the DOM of 'this'-nodes and then return this, which will then be used to populate the fields in the Grid or Form UI.

    Hope this helps.