Figaro - The XML Database for the .NET Framework
Defining Variables
Send Feedback
Figaro - the XML Database for the .NET Framework
Figaro - The XML Database for the .NET Framework

In XQuery FLWOR expressions, you can set variables using the let clause. In addition to this, you can use variables that are defined by Figaro. You define these variables using SetVariableValue.

You can declare as many variables this way as you need. Note that the variables that you declare this way can only be used from within a predicate. For example:

CopyC#
using (var mgr = new XmlManager(ManagerInitOptions.AllowExternalAccess) { DefaultContainerType = XmlContainerType.WholeDocContainer })
{
    using (var cont = mgr.OpenContainer(baseUri + testdb,ContainerSettings.Create))
    {
        //create the query context
        var queryContext = mgr.CreateQueryContext(EvaluationType.Eager);
        //set some namespace values
        queryContext.SetNamespace("fruits","http://groceryItem.dbxml/fruits");
        queryContext.SetNamespace("vegetables", "http://groceryItem.dbxml/vegetables");
        cont.AddAlias("testdb");
        queryContext.EvaluationType = EvaluationType.Eager;
        queryContext.SetVariableValue("myVar", "Artichoke");
        string xquery = "collection('testdb')/product[item=$myVar]";
        //ALWAYS close the container!
        cont.Close();
    }
}
Figaro - The XML Database for the .NET Framework

Copyright © 2008-2009 Endpoint Systems. All rights reserved.