Пример #1
0
 public virtual void TestSelectUnCommitedObject3()
 {
     DeleteBase(BaseName);
     // Create instance
     var sport = new Sport("volley-ball");
     IOdb odb = null;
     try
     {
         // Open the database
         odb = Open(BaseName);
         // Store the object
         odb.Store(sport);
     }
     finally
     {
         if (odb != null)
         {
             // Close the database
             odb.Close();
         }
     }
     try
     {
         // Open the database
         odb = Open(BaseName);
         // Let's insert a tennis player
         var agassi = new Player("André Agassi", new DateTime(), new Sport("Tennis"));
         odb.Store(agassi);
         IQuery query = odb.Query<Player>();
         query.Descend("favoriteSport.name").Constrain((object) "volley-ball").Equal();
         var players = query.Execute<Player>();
         Println("\nStep 4 : Players of Voller-ball");
         var i = 1;
         // display each object
         while (players.HasNext())
             Println((i++) + "\t: " + players.Next());
     }
     finally
     {
         if (odb != null)
         {
             // Close the database
             odb.Close();
         }
     }
     DeleteBase(BaseName);
 }
Пример #2
0
 public virtual void TestSelectUnCommitedObject4()
 {
     DeleteBase(BaseName);
     // Create instance
     var sport = new Sport("volley-ball");
     IOdb odb = null;
     try
     {
         // Open the database
         odb = Open(BaseName);
         // Store the object
         odb.Store(sport);
     }
     finally
     {
         if (odb != null)
         {
             // Close the database
             odb.Close();
         }
     }
     // Create instance
     var volleyball = new Sport("volley-ball");
     // Create 4 players
     var player1 = new Player("olivier", new DateTime(), volleyball);
     var player2 = new Player("pierre", new DateTime(), volleyball);
     var player3 = new Player("elohim", new DateTime(), volleyball);
     var player4 = new Player("minh", new DateTime(), volleyball);
     // Create two teams
     var team1 = new Team("Paris");
     var team2 = new Team("Montpellier");
     // Set players for team1
     team1.AddPlayer(player1);
     team1.AddPlayer(player2);
     // Set players for team2
     team2.AddPlayer(player3);
     team2.AddPlayer(player4);
     // Then create a volley ball game for the two teams
     var game = new Game(new DateTime(), volleyball, team1, team2);
     odb = null;
     try
     {
         // Open the database
         odb = Open(BaseName);
         // Store the object
         odb.Store(game);
     }
     finally
     {
         if (odb != null)
         {
             // Close the database
             odb.Close();
         }
     }
     try
     {
         // Open the database
         odb = Open(BaseName);
         IQuery query = odb.Query<Player>();
         query.Descend("name").Constrain((object) "olivier").Equal();
         var players = query.Execute<Player>();
         Println("\nStep 3 : Players with name olivier");
         var i = 1;
         // display each object
         while (players.HasNext())
             Println((i++) + "\t: " + players.Next());
     }
     finally
     {
         if (odb != null)
         {
             // Close the database
             odb.Close();
         }
     }
     try
     {
         // Open the database
         odb = Open(BaseName);
         // Let's insert a tennis player
         var agassi = new Player("André Agassi", new DateTime(), new Sport("Tennis"));
         var oid = odb.Store(agassi);
         IQuery query = odb.Query<Player>();
         query.Descend("favoriteSport.name").Constrain((object) "volley-ball").Equal();
         var players = query.Execute<Player>();
         Println("\nStep 4 : Players of Voller-ball");
         var i = 1;
         // display each object
         while (players.HasNext())
             Println((i++) + "\t: " + players.Next());
     }
     finally
     {
         if (odb != null)
         {
             // Close the database
             odb.Close();
         }
     }
     DeleteBase(BaseName);
 }
Пример #3
0
Файл: Team.cs Проект: danfma/NDB
 public virtual void AddPlayer(Player player)
 {
     players.Add(player);
 }