Example #1
0
 private ResultsetReader(Resultset source, ResultsetReader parent)
 {
     m_source = source;
     m_settings = parent.m_settings;
     m_nameTable = parent.m_nameTable;
     m_queue = new Queue<object>();
     m_createRoot = false;
     CreateSchema("dummy", source.RowType.GetSchemaTable());
 }
Example #2
0
 public override object Execute(object context, object[] args, XmlDocument xmlResult)
 {
     if (context != null)
     {
         XmlNode node = context as XmlNode;
         if (node == null)
         {
             if (context is Resultset)
             {
                 XmlReader reader = new ResultsetReader((Resultset)context,
                     "context", _command.Context.GetSettings());
                 XQueryDocument tmp = new XQueryDocument(reader);
                 _command.ContextItem = tmp.CreateNavigator();
             }
             else
                 throw new ESQLException(
                     String.Format(Properties.Resources.XmlQueryContextMustBeANode, context), null);
         }
         else
             _command.ContextItem = node.CreateNavigator();
     }
     if (args != null)
     {
         for (int k = 0; k < args.Length; k++)
         {
             XQueryParameter param = _command.Parameters[k];
             object val = args[k];
             if (val is Resultset)
             {
                 XmlReader reader = new ResultsetReader((Resultset)val,
                     XmlConvert.EncodeName(param.LocalName), _command.Context.GetSettings());
                 XQueryDocument tmp = new XQueryDocument(reader);
                 param.Value = tmp.CreateNavigator();
             }
             else if (val is XmlNode)
                 param.Value = ((XmlNode)val).CreateNavigator();
             else if (val is XmlNodeList)
                 param.Value = new  XmlNodeListIterator((XmlNodeList)val);
             else
                 param.Value = val;
         }
     }
     XQueryNodeIterator iter = _command.Execute();
     DOMConverter converter = new DOMConverter(xmlResult);
     XmlDataAccessor.NodeList res = new XmlDataAccessor.NodeList();
     while (iter.MoveNext())
         res.Add(converter.ToXmlNode(iter.Current));
     if (res.Count == 1)
         return res[0];
     return res;
 }