Using classic T-SQL if we wanted to get all this data out we could join the two tables and then we would get a longer flat record that repeated the data for the order in every record as shown below.
With FOR XML we can leverage SQL Server's built in heuristics that will create an XML structure for us that better represents the parent child relationship that is an order and line items. This query turns out to be very easy as seen in the following query.
select * from [Order] JOIN OrderLine ON Id = OrderId FOR XML AUTO, ELEMENTS The resulting XML is also very simple as shown below.
<
Order
>
Id
>47</
OrderNumber
>3774632</
CustomerName
>John Doe</
CustomerAddress1
>123 Fake St</
CustomerState
>IL</
OrderTotal
>247.54</
OrderLine
>49</
OrderId
ItemNumber
>54346</
Quantity
>1</
UnitCost
>2.475400000000000e+002</
Description
>Some Item</
</
>50</
>44352</
>2</
>1.542500000000000e+002</
>Another Item</
After this everything works exactly as you would expect and we can continue using a pattern that has been well developed and tested over time.
Another important place to find a huge amount of BizTalk related articles is the TechNet Wiki itself. The best entry point is BizTalk Server Resources on the TechNet Wiki
Great article, good work Dan!
Where is the use of WCF-SQL with XML?