public static void Main(string[] args) { try { // initialize timer Stopwatch watch = new Stopwatch(); watch.Start(); // create session Session session = new Session("localhost", 1984, "admin", "admin"); // version 1: perform command and print returned string Console.WriteLine(session.Execute("info")); // version 2 (faster): perform command and pass on result to output stream Stream stream = Console.OpenStandardOutput(); session.Execute("xquery 1 to 10", stream); // close session session.Close(); // print time needed Console.WriteLine("\n" + watch.ElapsedMilliseconds + " ms."); } catch (IOException e) { // print exception Console.WriteLine(e.Message); } }
public static void Main(string[] args) { try { // create session Session session = new Session("localhost", 1984, "admin", "admin"); // define InputStream MemoryStream ms = new MemoryStream( System.Text.Encoding.UTF8.GetBytes("<xml>Hello World!</xml>")); // create database session.Create("database", ms); Console.WriteLine(session.Info); // run query on database Console.WriteLine(session.Execute("xquery /")); // drop database session.Execute("drop db database"); // close session session.Close(); } catch (IOException e) { // print exception Console.WriteLine(e.Message); } }
public static void Main(string[] args) { try { // create session Session session1 = new Session("localhost", 1984, "admin", "admin"); Session session2 = new Session("localhost", 1984, "admin", "admin"); session1.Execute("create event messenger"); session2.Watch("messenger", new Notification()); session2.Query("for $i in 1 to 1000000 where $i = 0 return $i").Execute(); session1.Query("db:event('messenger', 'Hello World!')").Execute(); session2.Unwatch("messenger"); session1.Execute("drop event messenger"); // close session session1.Close(); session2.Close(); } catch (IOException e) { // print exception Console.WriteLine(e.Message); } }