コード例 #1
0
            public void Prepare()
            {
                using (ISession session = tc.OpenNewSession())
                    using (ITransaction txn = session.BeginTransaction())
                    {
                        _stateProvince = new StateProvince {
                            Name = "IL"
                        };

                        _zoo1 = new Zoo
                        {
                            Name    = "Zoo",
                            Address = new Address
                            {
                                Street        = "1313 Mockingbird Lane",
                                City          = "Anywhere",
                                StateProvince = StateProvince,
                                Country       = "USA"
                            },
                            Mammals = new Dictionary <string, Mammal>()
                        };

                        _zooMammal1 = new Mammal {
                            Description = "zooMammal1", Zoo = Zoo1
                        };
                        Zoo1.Mammals.Add("type1", ZooMammal1);

                        _zooMammal2 = new Mammal {
                            Description = "zooMammal2", Zoo = Zoo1
                        };
                        Zoo1.Mammals.Add("type2", ZooMammal2);

                        _zoo2 = new Zoo
                        {
                            Name    = "A Zoo",
                            Address = new Address
                            {
                                Street        = "1313 Mockingbird Lane",
                                City          = "Anywhere",
                                StateProvince = StateProvince,
                                Country       = "USA"
                            }
                        };

                        _zoo3 = new Zoo
                        {
                            Name    = "Zoo",
                            Address = new Address
                            {
                                Street        = "1312 Mockingbird Lane",
                                City          = "Anywhere",
                                StateProvince = StateProvince,
                                Country       = "USA"
                            }
                        };

                        _zoo4 = new Zoo
                        {
                            Name    = "Duh Zoo",
                            Address = new Address
                            {
                                Street        = "1312 Mockingbird Lane",
                                City          = "Nowhere",
                                StateProvince = StateProvince,
                                Country       = "USA"
                            }
                        };

                        session.Save(StateProvince);
                        session.Save(ZooMammal1);
                        session.Save(ZooMammal2);
                        session.Save(Zoo1);
                        session.Save(Zoo2);
                        session.Save(Zoo3);
                        session.Save(Zoo4);

                        txn.Commit();
                    }

                _zoosWithSameName = new HashSet <Zoo>();
                ZoosWithSameName.Add(Zoo1);
                ZoosWithSameName.Add(Zoo3);

                _zoosWithSameAddress = new HashSet <Zoo>();
                ZoosWithSameAddress.Add(Zoo1);
                ZoosWithSameAddress.Add(Zoo2);
            }
コード例 #2
0
			public void Prepare()
			{
				using (ISession session = tc.OpenNewSession())
				using (ITransaction txn = session.BeginTransaction())
				{
					_stateProvince = new StateProvince {Name = "IL"};

					_zoo1 = new Zoo
					{
						Name = "Zoo",
						Address = new Address
						{
							Street = "1313 Mockingbird Lane",
							City = "Anywhere",
							StateProvince = StateProvince,
							Country = "USA"
						},
						Mammals = new Dictionary<string, Mammal>()
					};

					_zooMammal1 = new Mammal {Description = "zooMammal1", Zoo = Zoo1};
					Zoo1.Mammals.Add("type1", ZooMammal1);

					_zooMammal2 = new Mammal {Description = "zooMammal2", Zoo = Zoo1};
					Zoo1.Mammals.Add("type2", ZooMammal2);

					_zoo2 = new Zoo
					{
						Name = "A Zoo",
						Address = new Address
						{
							Street = "1313 Mockingbird Lane",
							City = "Anywhere",
							StateProvince = StateProvince,
							Country = "USA"
						}
					};

					_zoo3 = new Zoo
					{
						Name = "Zoo",
						Address = new Address
						{
							Street = "1312 Mockingbird Lane",
							City = "Anywhere",
							StateProvince = StateProvince,
							Country = "USA"
						}
					};

					_zoo4 = new Zoo
					{
						Name = "Duh Zoo",
						Address = new Address
						{
							Street = "1312 Mockingbird Lane",
							City = "Nowhere",
							StateProvince = StateProvince,
							Country = "USA"
						}
					};

					session.Save(StateProvince);
					session.Save(ZooMammal1);
					session.Save(ZooMammal2);
					session.Save(Zoo1);
					session.Save(Zoo2);
					session.Save(Zoo3);
					session.Save(Zoo4);

					txn.Commit();
				}

				_zoosWithSameName = new HashSet<Zoo>();
				ZoosWithSameName.Add(Zoo1);
				ZoosWithSameName.Add(Zoo3);

				_zoosWithSameAddress = new HashSet<Zoo>();
				ZoosWithSameAddress.Add(Zoo1);
				ZoosWithSameAddress.Add(Zoo2);
			}
コード例 #3
0
            public async Task PrepareAsync(CancellationToken cancellationToken = default(CancellationToken))
            {
                using (ISession session = tc.OpenNewSession())
                    using (ITransaction txn = session.BeginTransaction())
                    {
                        _stateProvince = new StateProvince {
                            Name = "IL"
                        };

                        _zoo1 = new Zoo
                        {
                            Name    = "Zoo",
                            Address = new Address
                            {
                                Street        = "1313 Mockingbird Lane",
                                City          = "Anywhere",
                                StateProvince = StateProvince,
                                Country       = "USA"
                            },
                            Mammals = new Dictionary <string, Mammal>()
                        };

                        _zooMammal1 = new Mammal {
                            Description = "zooMammal1", Zoo = Zoo1
                        };
                        Zoo1.Mammals.Add("type1", ZooMammal1);

                        _zooMammal2 = new Mammal {
                            Description = "zooMammal2", Zoo = Zoo1
                        };
                        Zoo1.Mammals.Add("type2", ZooMammal2);

                        _zoo2 = new Zoo
                        {
                            Name    = "A Zoo",
                            Address = new Address
                            {
                                Street        = "1313 Mockingbird Lane",
                                City          = "Anywhere",
                                StateProvince = StateProvince,
                                Country       = "USA"
                            }
                        };

                        _zoo3 = new Zoo
                        {
                            Name    = "Zoo",
                            Address = new Address
                            {
                                Street        = "1312 Mockingbird Lane",
                                City          = "Anywhere",
                                StateProvince = StateProvince,
                                Country       = "USA"
                            }
                        };

                        _zoo4 = new Zoo
                        {
                            Name    = "Duh Zoo",
                            Address = new Address
                            {
                                Street        = "1312 Mockingbird Lane",
                                City          = "Nowhere",
                                StateProvince = StateProvince,
                                Country       = "USA"
                            }
                        };

                        await(session.SaveAsync(StateProvince, cancellationToken));
                        await(session.SaveAsync(ZooMammal1, cancellationToken));
                        await(session.SaveAsync(ZooMammal2, cancellationToken));
                        await(session.SaveAsync(Zoo1, cancellationToken));
                        await(session.SaveAsync(Zoo2, cancellationToken));
                        await(session.SaveAsync(Zoo3, cancellationToken));
                        await(session.SaveAsync(Zoo4, cancellationToken));

                        await(txn.CommitAsync(cancellationToken));
                    }

                _zoosWithSameName = new HashSet <Zoo>();
                ZoosWithSameName.Add(Zoo1);
                ZoosWithSameName.Add(Zoo3);

                _zoosWithSameAddress = new HashSet <Zoo>();
                ZoosWithSameAddress.Add(Zoo1);
                ZoosWithSameAddress.Add(Zoo2);
            }