IBM Database Add-Ins for Visual Studio

Setting up .NET Applications to Write LINQ to XML Queries on XML Data

You can set up your .NET application with selected XML documents and references and then write LINQ to XML queries on the XML data in any of the following locations:

You can use this feature in the following types of .NET applications:

This feature is available both for stand-alone XML documents and for XML documents and XML schemas on the following data servers:

Prerequisites:

To set up a .NET application to write LINQ to XML queries on XML data:

  1. In the Solution Explorer, right-click the project node of your application, and then select Add IBM XML Reference on the shortcut menu.

    The Select XML Source for Project window opens.

  2. Optional: Select the DB2 data server that you want to connect to the Visual Studio project.

    This step is required if you want to write queries on XML data in your DB2 database or on an XML schema in the XML Schema Repository.

  3. Select the option that indicates the XML source that you want to use.
    • If you select Use registered XML schema, select the XML schema owner and name from the lists.
    • If you select Use document stored in column, click Ellipsis button and then select the database table and XML column in the Select XML Column window.
    • If you select Use document from file, click Ellipsis button and then select the XML file from the file system.
  4. To generate a mapping class with the sample LINQ to XML query code, select the Generate class to map to XML source check box.
  5. Click OK.
  6. Optional: If you selected Use document from file in step 3, register the generated XML schema in the XML Schema Repository.

If you use an XML schema as the XML source, a sample XML document is generated from the schema. If you use a document as the XML source, an XML schema is generated for the XML document. Both the XML document file and the XML schema file are copied to the directory of the Visual Studio project. References to both files are added to the project.

Sample code for how to write a LINQ to XML query on the XML document is added to your Visual Studio project.


See Also

Overview: Setting up .NET Applications to Write LINQ to XML Queries on XML Data | Managing XML Data


.NET Development Forum   DB2 FAQs   IDS FAQs

© Copyright IBM Corporation 2002, 2019. All Rights Reserved.