Ejemplo n.º 1
0
 public virtual void TestArray1()
 {
     NeoDatis.Odb.ODB odb = null;
     try
     {
         DeleteBase("array1.neodatis");
         odb = Open("array1.neodatis");
         decimal nb = odb.Count(new CriteriaQuery(typeof(
                                                      PlayerWithArray)));
         PlayerWithArray player = new PlayerWithArray
                                      ("kiko");
         player.AddGame("volley-ball");
         player.AddGame("squash");
         player.AddGame("tennis");
         player.AddGame("ping-pong");
         odb.Store(player);
         odb.Close();
         odb = Open("array1.neodatis");
         NeoDatis.Odb.Objects <PlayerWithArray> l = odb.GetObjects <PlayerWithArray>(true);
         AssertEquals(nb + 1, l.Count);
         // gets first player
         PlayerWithArray player2 = l.GetFirst();
         AssertEquals(player.ToString(), player2.ToString());
     }
     catch (System.Exception e)
     {
         if (odb != null)
         {
             odb.Rollback();
             odb = null;
         }
         Console.WriteLine(e);
         throw e;
     }
     finally
     {
         if (odb != null)
         {
             odb.Close();
         }
         DeleteBase("array1.neodatis");
     }
 }
Ejemplo n.º 2
0
        public virtual void TestArray1()
        {
            IOdb odb = null;

            try
            {
                DeleteBase("array1.ndb");
                odb = Open("array1.ndb");
                decimal nb     = odb.Query <PlayerWithArray>().Count();
                var     player = new PlayerWithArray("kiko");
                player.AddGame("volley-ball");
                player.AddGame("squash");
                player.AddGame("tennis");
                player.AddGame("ping-pong");
                odb.Store(player);
                odb.Close();
                odb = Open("array1.ndb");
                var query = odb.Query <PlayerWithArray>();
                var l     = query.Execute <PlayerWithArray>(true);
                AssertEquals(nb + 1, l.Count);
                // gets first player
                var player2 = l.GetFirst();
                AssertEquals(player.ToString(), (string)player2.ToString());
            }
            catch (Exception e)
            {
                if (odb != null)
                {
                    odb.Rollback();
                    odb = null;
                }
                Console.WriteLine(e);
                throw e;
            }
            finally
            {
                if (odb != null)
                {
                    odb.Close();
                }
                DeleteBase("array1.ndb");
            }
        }
Ejemplo n.º 3
0
		/// <exception cref="System.Exception"></exception>
		public virtual void TestArrayQuery()
		{
			NeoDatis.Odb.ODB odb = null;
			try
			{
				DeleteBase("array1.neodatis");
				odb = Open("array1.neodatis");
				decimal nb = odb.Count(new CriteriaQuery(typeof(
					PlayerWithArray)));
				PlayerWithArray player = new PlayerWithArray
					("kiko");
				player.AddGame("volley-ball");
				player.AddGame("squash");
				player.AddGame("tennis");
				player.AddGame("ping-pong");
				odb.Store(player);
				odb.Close();
				odb = Open("array1.neodatis");
                NeoDatis.Odb.Objects<PlayerWithArray> l = odb.GetObjects < PlayerWithArray>(new CriteriaQuery(Where.Contain("games", "tennis")));
				AssertEquals(nb + 1, l.Count);
			}
			catch (System.Exception e)
			{
				if (odb != null)
				{
					odb.Rollback();
					odb = null;
				}
				throw;
			}
			finally
			{
				if (odb != null)
				{
					odb.Close();
				}
				DeleteBase("array1.neodatis");
			}
		}
Ejemplo n.º 4
0
        public virtual void TestArrayQuery()
        {
            DeleteBase("array4.ndb");
            decimal nb;

            using (var odb = Open("array4.ndb"))
            {
                nb = odb.Query <PlayerWithArray>().Count();
                var player = new PlayerWithArray("kiko");
                player.AddGame("volley-ball");
                player.AddGame("squash");
                player.AddGame("tennis");
                player.AddGame("ping-pong");
                odb.Store(player);
            }

            using (var odb = Open("array4.ndb"))
            {
                var query = odb.Query <PlayerWithArray>();
                query.Descend("games").Constrain("tennis").Contains();
                var l = query.Execute <PlayerWithArray>();
                AssertEquals(nb + 1, l.Count);
            }
        }