Skip to content
Muhamamd Miftah edited this page Oct 22, 2019 · 3 revisions

LinqToXsdCore

The contents of this wiki is intended to preserve some of the old documentation Microsoft wrote in the early development of LinqToXsd. This wiki details the lower-level technical features of LinqToXsd.

What is LINQ to XSD?

The LINQ to XSD technology provides .NET developers with support for typed XML programming. LINQ to XSD contributes to the LINQ project (.NET Language Integrated Query); in particular, LINQ to XSD enhances the existing LINQ to XML technology. To get an idea, consider the following C# fragment for a LINQ to XML query that computes the total over the items in a XML tree for a purchase order:

(from item in purchaseOrder.Elements("Item")
      select (double)item.Element("Price")
           * (int)item.Element("Quantity")
     ).Sum();

Using LINQ to XSD, .NET developers may instead write `typed’ code as follows:

     (from item in purchaseOrder.Item
      select item.Price * item.Quantity
     ).Sum();

LINQ to XSD facilitates XML schemas (XSD), which are automatically mapped to object models so that XML data may be processed in typed manner within the OO paradigm. To this end, the generated classes enforce various validation constraints imposed by the input schema. In this respect, LINQ to XSD is similar to existing technologies for so-called X/O mapping or XML data binding. An important aspect of LINQ to XSD though is its foundation on ‘XML objects’ as opposed to ‘plain objects’. That is, the object models, generated from XML schemas, provide XML semantics in terms of XML fidelity and programming idioms, thereby providing a better programming environment for XML-related development tasks. To this end, the generated classes model typed views on untyped XML trees. LINQ to XSD enhances LINQ to XML. Familiar XML programming idioms of LINQ to XML are complemented by typed variations in LINQ to XSD. In particular, typed member access can be used in most cases, and untyped tree access is available as a last resort.

Clone this wiki locally