コード例 #1
0
ファイル: TestList.cs プロジェクト: ekicyou/pasta
        public virtual void TestBigList()
        {
            string baseName = GetBaseName();
            NeoDatis.Odb.ODB odb = Open(baseName);
            int size = 10000;
            int size2 = 4;
            long t0 = DateTime.Now.Ticks;
            for (int i = 0; i < size; i++)
            {
                PlayerWithList player = new PlayerWithList("player " + i);
                for (int j = 0; j < size2; j++)
                {
                    player.AddGame("game " + j);
                }
                odb.Store(player);
            }
            odb.Close();
            long t1 = DateTime.Now.Ticks;
            Console.WriteLine("insert : " + (t1 - t0) / 10000);

            NeoDatis.Odb.ODB odb2 = Open(baseName);
            NeoDatis.Odb.Objects<PlayerWithList> l = odb2.GetObjects<PlayerWithList>(false);
            long t2 = DateTime.Now.Ticks;
            AssertEquals(size, l.Count);
            Console.WriteLine("get objects " +l.Count + " : " + (t2 - t1) / 10000);
            odb2.Close();
            DeleteBase(baseName);
        }
コード例 #2
0
ファイル: TestList.cs プロジェクト: ekicyou/pasta
		/// <exception cref="System.Exception"></exception>
		public virtual void TestList2()
		{
			DeleteBase("list1.neodatis");
			NeoDatis.Odb.ODB odb = Open("list1.neodatis");
			long nb = odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof(
				PlayerWithList)));
			PlayerWithList player = new PlayerWithList
				("kiko");
			player.SetGames(null);
			odb.Store(player);
			odb.Close();
			NeoDatis.Odb.ODB odb2 = Open("list1.neodatis");
			NeoDatis.Odb.Objects l = odb2.GetObjects<PlayerWithList>(true);
			AssertEquals(nb + 1, l.Count);
			odb2.Close();
			DeleteBase("list1.neodatis");
		}
コード例 #3
0
ファイル: TestList.cs プロジェクト: ekicyou/pasta
		/// <exception cref="System.Exception"></exception>
		public virtual void TestList1WithNull()
		{
			DeleteBase("list1.neodatis");
			NeoDatis.Odb.ODB odb = Open("list1.neodatis");
			long nb = odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof(
				PlayerWithList)));
			PlayerWithList player = new PlayerWithList("kiko");
			player.AddGame("volley-ball");
			player.AddGame("squash");
			player.AddGame("tennis");
			player.AddGame(null);
			odb.Store(player);
			odb.Close();
			NeoDatis.Odb.ODB odb2 = Open("list1.neodatis");
			NeoDatis.Odb.Objects<PlayerWithList> l = odb2.GetObjects<PlayerWithList>(true);
			AssertEquals(nb + 1, l.Count);
			// gets last player
			PlayerWithList player2 = (PlayerWithList)l.GetFirst();
			AssertEquals(player.GetGame(2), player2.GetGame(2));
			odb2.Close();
			DeleteBase("list1.neodatis");
		}
コード例 #4
0
ファイル: TestList.cs プロジェクト: ekicyou/pasta
		/// <exception cref="System.Exception"></exception>
		public virtual void TestCollectionWithContain()
		{
			NeoDatis.Odb.ODB odb = null;
			string baseName = GetBaseName();
			try
			{
				odb = Open(baseName);
				long nb = odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof(
					PlayerWithList)));
				PlayerWithList player = new PlayerWithList
					("kiko");
				player.AddGame("volley-ball");
				player.AddGame("squash");
				player.AddGame("tennis");
				player.AddGame("ping-pong");
				odb.Store(player);
				odb.Close();
				odb = Open(baseName);
				NeoDatis.Odb.Objects<PlayerWithList> l = odb.GetObjects<PlayerWithList>(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();
				}
			}
		}