static void CreateDatabaseTestUsingContext()
 {
     using (var context = new TestDatabaseContext())
     using (var database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
     {
         var documents = database.Query("select from OUser");
         foreach (var item in documents)
         {
             System.Console.WriteLine("Name: {0} Status: {1}",
                 item.GetField<string>("name"), item.GetField<string>("status"));
         }
     }
 }
Beispiel #2
0
 static void CreateDatabaseTestUsingContext()
 {
     using (var context = new TestDatabaseContext())
         using (var database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
         {
             var documents = database.Query("select from OUser");
             foreach (var item in documents)
             {
                 System.Console.WriteLine("Name: {0} Status: {1}",
                                          item.GetField <string>("name"), item.GetField <string>("status"));
             }
         }
 }
Beispiel #3
0
        static void Main(string[] args)
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
                {
                    database
                    .Create.Class("Person")
                    .Extends <OVertex>()
                    .Run();

                    database
                    .Create.Class("Spouse")
                    .Extends <OVertex>()
                    .Run();

                    ODocument person1 = database
                                        .Create.Vertex("Person")
                                        .Set("Name", "Johny")
                                        .Run();

                    ODocument spouse1 = database
                                        .Create.Vertex("Spouse")
                                        .Set("Name", "Mary")
                                        .Run();

                    ODocument spouse2 = database
                                        .Create.Vertex("Spouse")
                                        .Set("Name", "Julia")
                                        .Run();

                    // TODO: check what happens in command execution
                    ODocument edge1 = database
                                      .Create.Edge <OEdge>()
                                      .From(person1)
                                      .To(spouse1)
                                      .Run();

                    ODocument edge2 = database
                                      .Create.Edge <OEdge>()
                                      .From(person1)
                                      .To(spouse2)
                                      .Run();

                    List <ODocument> docs = database.Query("select Name from Person");
                }

                /*bool exit = false;
                 *
                 * using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
                 * {
                 *  database
                 *      .Create.Class("TestClass")
                 *      .Extends<OVertex>()
                 *      .Run();
                 *
                 *  database
                 *      .Create.Vertex("TestClass")
                 *      .Set("foo", "foo string value 1")
                 *      .Set("bar", 123)
                 *      .Run();
                 *
                 *  database
                 *      .Create.Vertex("TestClass")
                 *      .Set("foo", "foo string value 2")
                 *      .Set("bar", 1233)
                 *      .Run();
                 * }
                 *
                 * while (!exit)
                 * {
                 *  System.Console.WriteLine(
                 *      "Current pool size: {0} @ {1} : {2}",
                 *      OClient.DatabasePoolCurrentSize(TestConnection.GlobalTestDatabaseAlias),
                 *      DateTime.Now.ToString(),
                 *      Query().Count
                 *  );
                 *
                 *  string line = System.Console.ReadLine();
                 *
                 *  if (line.Equals("exit"))
                 *  {
                 *      exit = true;
                 *  }
                 * }*/
            }
        }
        static void ConnectionPoolTest()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
                {
                    database
                        .Create.Class("Person")
                        .Extends<OVertex>()
                        .Run();

                    database
                        .Create.Class("Spouse")
                        .Extends<OVertex>()
                        .Run();

                    ODocument person1 = database
                        .Create.Vertex("Person")
                        .Set("Name", "Johny")
                        .Run();

                    ODocument spouse1 = database
                        .Create.Vertex("Spouse")
                        .Set("Name", "Mary")
                        .Run();

                    ODocument spouse2 = database
                        .Create.Vertex("Spouse")
                        .Set("Name", "Julia")
                        .Run();

                    // TODO: check what happens in command execution
                    ODocument edge1 = database
                        .Create.Edge<OEdge>()
                        .From(person1)
                        .To(spouse1)
                        .Run();

                    ODocument edge2 = database
                        .Create.Edge<OEdge>()
                        .From(person1)
                        .To(spouse2)
                        .Run();

                    List<ODocument> docs = database.Query("select from Person");
                }

                bool exit = false;

                using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
                {
                    database
                        .Create.Class("TestClass")
                        .Extends<OVertex>()
                        .Run();

                    database
                        .Create.Vertex("TestClass")
                        .Set("foo", "foo string value 1")
                        .Set("bar", 123)
                        .Run();

                    database
                        .Create.Vertex("TestClass")
                        .Set("foo", "foo string value 2")
                        .Set("bar", 1233)
                        .Run();
                }

                while (!exit)
                {
                    System.Console.WriteLine(
                        "Current pool size: {0} @ {1} : {2}",
                        OClient.DatabasePoolCurrentSize(TestConnection.GlobalTestDatabaseAlias),
                        DateTime.Now.ToString(),
                        Query().Count
                    );

                    string line = System.Console.ReadLine();

                    if (line.Equals("exit"))
                    {
                        exit = true;
                    }
                }
            }
        }