Merge two XDocuments

by Daniel Halan 14. September 2009 21:43

Was looking for a standard way of merging two XML Documents using XDocument objects, but found none with duplicate checking. You can use this short snippet bellow to merge two XDocuments, but then duplicate elements will also populate the merged document, so here comes a handy little method that also checks for duplicate items.

Simple Merge (Copy all)
XDocument xdoc = XDocument.Load("a.xml");
xdoc.Root.Add( XDocument.Load("b.xml").Root.Elements() );

Merge with duplicate element check (C# Class)
HalanTools.zip (0,71 KB)

Tags: ,

.NET | LINQ

CRM Fetch XML Size Limit

by Daniel Halan 11. September 2009 23:07

Recently I was working on a dynamic Fetch XML query that was adding a lot of conditions. During a batch run the CRM Service started to crash when the xml size got around ~135kb. My first thought was that there were a size limit of the SOAP message that we'd cross, but after further testing it would become evident that fetch queries has a limit of 2097 <condition> elements. That is 2097 per <filer> element. If a query has linked entities that has 0-2097 conditions then the main entity can have a maximum of 2095 conditions.


Tags: ,

.NET | CRM

Powered by BlogEngine.NET 1.6.1.2
Theme by Daniel Halan

About the author

Daniel Halan Daniel Halan systems architect at Logica in Sweden.

Working primary with Microsoft Dynamics CRM.

Complete Profile

The content of this site are my own personal opinions and do not represent my employer's view in anyway.

Follow me on Twitter