当前位置: 首页>>代码示例>>C#>>正文


C# TestData.Release方法代码示例

本文整理汇总了C#中TestData.Release方法的典型用法代码示例。如果您正苦于以下问题:C# TestData.Release方法的具体用法?C# TestData.Release怎么用?C# TestData.Release使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestData的用法示例。


在下文中一共展示了TestData.Release方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SecondLevelCachedCollectionsFiltering

		public void SecondLevelCachedCollectionsFiltering()
		{
			TestData testData = new TestData(this);
			testData.Prepare();

			ISession session = OpenSession();

			// Force a collection into the second level cache, with its non-filtered elements
			Salesperson sp = (Salesperson) session.Load(typeof(Salesperson), testData.steveId);
			NHibernateUtil.Initialize(sp.Orders);
			ICollectionPersister persister = ((ISessionFactoryImplementor) sessions)
				.GetCollectionPersister(typeof(Salesperson).FullName + ".Orders");
			Assert.IsTrue(persister.HasCache, "No cache for collection");
			CacheKey cacheKey =
				new CacheKey(testData.steveId, persister.KeyType, persister.Role, EntityMode.Poco, (ISessionFactoryImplementor) sessions);
			CollectionCacheEntry cachedData = (CollectionCacheEntry)persister.Cache.Cache.Get(cacheKey);
			Assert.IsNotNull(cachedData, "collection was not in cache");

			session.Close();

			session = OpenSession();
			session.EnableFilter("fulfilledOrders").SetParameter("asOfDate", testData.lastMonth);
			sp = (Salesperson) session.CreateQuery("from Salesperson as s where s.id = :id")
			                   	.SetInt64("id", testData.steveId)
			                   	.UniqueResult();
			Assert.AreEqual(1, sp.Orders.Count, "Filtered-collection not bypassing 2L-cache");

			CollectionCacheEntry cachedData2 = (CollectionCacheEntry)persister.Cache.Cache.Get(cacheKey);
			Assert.IsNotNull(cachedData2, "collection no longer in cache!");
			Assert.AreSame(cachedData, cachedData2, "Different cache values!");

			session.Close();

			session = OpenSession();
			session.EnableFilter("fulfilledOrders").SetParameter("asOfDate", testData.lastMonth);
			sp = (Salesperson) session.Load(typeof(Salesperson), testData.steveId);
			Assert.AreEqual(1, sp.Orders.Count, "Filtered-collection not bypassing 2L-cache");

			session.Close();

			// Finally, make sure that the original cached version did not get over-written
			session = OpenSession();
			sp = (Salesperson) session.Load(typeof(Salesperson), testData.steveId);
			Assert.AreEqual(2, sp.Orders.Count, "Actual cached version got over-written");

			session.Close();
			testData.Release();
		}
开发者ID:NikGovorov,项目名称:nhibernate-core,代码行数:48,代码来源:DynamicFilterTest.cs

示例2: FiltersWithQueryCache

		public void FiltersWithQueryCache()
		{
			TestData testData = new TestData(this);
			testData.Prepare();

			ISession session = OpenSession();
			session.EnableFilter("regionlist").SetParameterList("regions", new string[] {"LA", "APAC"});
			session.EnableFilter("fulfilledOrders").SetParameter("asOfDate", testData.lastMonth);

			// test retreival through hql with the collection as non-eager
			IList salespersons = session.CreateQuery("select s from Salesperson as s").SetCacheable(true).List();
			Assert.AreEqual(1, salespersons.Count, "Incorrect salesperson count");

			// Try a second time, to make use of query cache
			salespersons = session.CreateQuery("select s from Salesperson as s").SetCacheable(true).List();
			Assert.AreEqual(1, salespersons.Count, "Incorrect salesperson count");

			session.Clear();

			// test retreival through hql with the collection join fetched
			salespersons =
				session.CreateQuery("select s from Salesperson as s left join fetch s.Orders").SetCacheable(true).List();
			Assert.AreEqual(1, salespersons.Count, "Incorrect salesperson count");

			// A second time, to make use of query cache
			salespersons =
				session.CreateQuery("select s from Salesperson as s left join fetch s.Orders").SetCacheable(true).List();
			Assert.AreEqual(1, salespersons.Count, "Incorrect salesperson count");

			session.Close();
			testData.Release();
		}
开发者ID:NikGovorov,项目名称:nhibernate-core,代码行数:32,代码来源:DynamicFilterTest.cs

示例3: CombinedClassAndCollectionFiltersEnabled

		public void CombinedClassAndCollectionFiltersEnabled()
		{
			TestData testData = new TestData(this);
			testData.Prepare();

			ISession session = OpenSession();
			session.EnableFilter("regionlist").SetParameterList("regions", new string[] {"LA", "APAC"});
			session.EnableFilter("fulfilledOrders").SetParameter("asOfDate", testData.lastMonth);

			// test retreival through hql with the collection as non-eager
			IList salespersons = session.CreateQuery("select s from Salesperson as s").List();
			Assert.AreEqual(1, salespersons.Count, "Incorrect salesperson count");
			Salesperson sp = (Salesperson) salespersons[0];
			Assert.AreEqual(1, sp.Orders.Count, "Incorrect order count");

			session.Clear();

			// test retreival through hql with the collection join fetched
			salespersons = session.CreateQuery("select s from Salesperson as s left join fetch s.Orders").List();
			Assert.AreEqual(1, salespersons.Count, "Incorrect salesperson count");
			sp = (Salesperson) salespersons[0];
			Assert.AreEqual(sp.Orders.Count, 1, "Incorrect order count");

			session.Close();
			testData.Release();
		}
开发者ID:NikGovorov,项目名称:nhibernate-core,代码行数:26,代码来源:DynamicFilterTest.cs

示例4: ManyToManyBaseThruCriteria

		public void ManyToManyBaseThruCriteria()
		{
			TestData testData = new TestData(this);
			testData.Prepare();

			ISession session = OpenSession();

			IList result = session.CreateCriteria(typeof(Product))
				.Add(Expression.Eq("id", testData.prod1Id))
				.List();

			Product prod = (Product) result[0];

			//long initLoadCount = sessions.Statistics.CollectionLoadCount;
			//long initFetchCount = sessions.Statistics.CollectionFetchCount;

			// should already have been initialized...
			Assert.IsTrue(NHibernateUtil.IsInitialized(prod.Categories),
			              "Load with join fetch of many-to-many did not trigger join fetch");
			int size = prod.Categories.Count;
			Assert.AreEqual(2, size, "Incorrect non-filtered collection count");

			//long currLoadCount = sessions.Statistics.CollectionLoadCount;
			//long currFetchCount = sessions.Statistics.CollectionFetchCount;

			//Assert.IsTrue(
			//    (initLoadCount == currLoadCount) && (initFetchCount == currFetchCount),
			//    "Load with join fetch of many-to-many did not trigger join fetch"
			//    );

			// make sure we did not get back a collection of proxies
			//long initEntityLoadCount = sessions.Statistics.EntityLoadCount;
			foreach (Category cat in prod.Categories)
			{
				Assert.IsTrue(NHibernateUtil.IsInitialized(cat),
				              "Load with join fetch of many-to-many did not trigger *complete* join fetch");
				//Console.WriteLine(" ===> " + cat.Name);
			}
			//long currEntityLoadCount = sessions.Statistics.EntityLoadCount;

			//Assert.IsTrue(
			//    (initEntityLoadCount == currEntityLoadCount),
			//    "Load with join fetch of many-to-many did not trigger *complete* join fetch"
			//    );

			session.Close();
			testData.Release();
		}
开发者ID:NikGovorov,项目名称:nhibernate-core,代码行数:48,代码来源:DynamicFilterTest.cs

示例5: ManyToManyFilterOnQuery

		public void ManyToManyFilterOnQuery()
		{
			TestData testData = new TestData(this);
			testData.Prepare();

			ISession session = OpenSession();
			session.EnableFilter("effectiveDate").SetParameter("asOfDate", DateTime.Today);

			IList result = session.CreateQuery("from Product p inner join fetch p.Categories").List();
			Assert.IsTrue(result.Count > 0, "No products returned from HQL many-to-many filter case");

			Product prod = (Product) result[0];

			Assert.IsNotNull(prod);
			Assert.AreEqual(1, prod.Categories.Count, "Incorrect Product.categories count for filter with HQL");

			session.Close();
			testData.Release();
		}
开发者ID:NikGovorov,项目名称:nhibernate-core,代码行数:19,代码来源:DynamicFilterTest.cs

示例6: ManyToManyOnCollectionLoadAfterHQL

		public void ManyToManyOnCollectionLoadAfterHQL()
		{
			TestData testData = new TestData(this);
			testData.Prepare();

			ISession session = OpenSession();
			session.EnableFilter("effectiveDate").SetParameter("asOfDate", DateTime.Today);

			// Force the categories to not get initialized here
			IList result = session.CreateQuery("from Product as p where p.id = :id")
				.SetInt64("id", testData.prod1Id)
				.List();
			Assert.IsTrue(result.Count > 0, "No products returned from HQL");

			Product prod = (Product) result[0];
			Assert.IsNotNull(prod);
			Assert.AreEqual(1, prod.Categories.Count, "Incorrect Product.categories count for filter on collection Load");

			session.Close();
			testData.Release();
		}
开发者ID:NikGovorov,项目名称:nhibernate-core,代码行数:21,代码来源:DynamicFilterTest.cs

示例7: ManyToManyFilterOnLoad

		public void ManyToManyFilterOnLoad()
		{
			TestData testData = new TestData(this);
			testData.Prepare();

			ISession session = OpenSession();
			session.EnableFilter("effectiveDate").SetParameter("asOfDate", DateTime.Today);

			Product prod = (Product) session.Get(typeof(Product), testData.prod1Id);

			//long initLoadCount = sessions.Statistics.CollectionLoadCount;
			//long initFetchCount = sessions.Statistics.CollectionFetchCount;

			// should already have been initialized...
			Assert.IsTrue(NHibernateUtil.IsInitialized(prod.Categories));
			int size = prod.Categories.Count;
			Assert.AreEqual(1, size, "Incorrect filtered collection count");

			//long currLoadCount = sessions.Statistics.CollectionLoadCount;
			//long currFetchCount = sessions.Statistics.CollectionFetchCount;

			//Assert.IsTrue(
			//    (initLoadCount == currLoadCount) && (initFetchCount == currFetchCount),
			//    "Load with join fetch of many-to-many did not trigger join fetch"
			//    );

			// make sure we did not get back a collection of proxies
			//long initEntityLoadCount = sessions.Statistics.EntityLoadCount;

			foreach (Category cat in prod.Categories)
			{
				Assert.IsTrue(NHibernateUtil.IsInitialized(cat),
				              "Load with join fetch of many-to-many did not trigger *complete* join fetch");
				//Console.WriteLine(" ===> " + cat.Name);
			}
			//long currEntityLoadCount = sessions.Statistics.EntityLoadCount;

			//Assert.IsTrue(
			//    (initEntityLoadCount == currEntityLoadCount),
			//    "Load with join fetch of many-to-many did not trigger *complete* join fetch"
			//    );

			session.Close();
			testData.Release();
		}
开发者ID:NikGovorov,项目名称:nhibernate-core,代码行数:45,代码来源:DynamicFilterTest.cs

示例8: ManyToManyFilterOnCriteria

		public void ManyToManyFilterOnCriteria()
		{
			TestData testData = new TestData(this);
			testData.Prepare();

			ISession session = OpenSession();
			session.EnableFilter("effectiveDate").SetParameter("asOfDate", DateTime.Today);

			Product prod = (Product) session.CreateCriteria(typeof(Product))
			                         	.SetResultTransformer(new DistinctRootEntityResultTransformer())
			                         	.Add(Expression.Eq("id", testData.prod1Id))
			                         	.UniqueResult();

			Assert.IsNotNull(prod);
			Assert.AreEqual(1, prod.Categories.Count, "Incorrect Product.categories count for filter");

			session.Close();
			testData.Release();
		}
开发者ID:NikGovorov,项目名称:nhibernate-core,代码行数:19,代码来源:DynamicFilterTest.cs

示例9: InStyleFilterParameter

		public void InStyleFilterParameter()
		{
			//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
			// one-to-many loading tests
			//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
			log.Info("Starting one-to-many collection loader filter tests.");
			TestData testData = new TestData(this);
			testData.Prepare();

			ISession session = OpenSession();
			session.EnableFilter("regionlist")
				.SetParameterList("regions", new string[] {"LA", "APAC"});

			log.Debug("Performing query of Salespersons");
			IList salespersons = session.CreateQuery("from Salesperson").List();
			Assert.AreEqual(1, salespersons.Count, "Incorrect salesperson count");

			session.Close();
			testData.Release();
		}
开发者ID:NikGovorov,项目名称:nhibernate-core,代码行数:20,代码来源:DynamicFilterTest.cs

示例10: OneToManyFilters

		public void OneToManyFilters()
		{
			//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
			// one-to-many loading tests
			//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
			log.Info("Starting one-to-many collection loader filter tests.");
			TestData testData = new TestData(this);
			testData.Prepare();

			ISession session = OpenSession();
			session.EnableFilter("seniorSalespersons")
				.SetParameter("asOfDate", testData.lastMonth);

			log.Info("Performing Load of Department...");
			Department department = (Department) session.Load(typeof(Department), testData.deptId);
			ISet<Salesperson> salespersons = department.Salespersons;
			Assert.AreEqual(1, salespersons.Count, "Incorrect salesperson count");

			session.Close();
			testData.Release();
		}
开发者ID:NikGovorov,项目名称:nhibernate-core,代码行数:21,代码来源:DynamicFilterTest.cs

示例11: GetFilters

		public void GetFilters()
		{
			//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
			// Get() test
			//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
			log.Info("Starting get() filter tests (eager assoc. fetching).");
			TestData testData = new TestData(this);
			testData.Prepare();

			ISession session = OpenSession();
			session.EnableFilter("region").SetParameter("region", "APAC");

			log.Info("Performing get()...");
			Salesperson salesperson = (Salesperson) session.Get(typeof(Salesperson), testData.steveId);
			Assert.IsNotNull(salesperson);
			Assert.AreEqual(1, salesperson.Orders.Count, "Incorrect order count");

			session.Close();
			testData.Release();
		}
开发者ID:NikGovorov,项目名称:nhibernate-core,代码行数:20,代码来源:DynamicFilterTest.cs

示例12: CriteriaQueryFilters

		public void CriteriaQueryFilters()
		{
			//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
			// Criteria-query test
			//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
			log.Info("Starting Criteria-query filter tests");
			TestData testData = new TestData(this);
			testData.Prepare();

			ISession session = OpenSession();
			session.EnableFilter("region").SetParameter("region", "APAC");

			session.EnableFilter("fulfilledOrders")
				.SetParameter("asOfDate", testData.lastMonth);

			session.EnableFilter("effectiveDate")
				.SetParameter("asOfDate", testData.lastMonth);

			log.Info("Criteria query against Salesperson...");
			IList salespersons = session.CreateCriteria(typeof(Salesperson))
				.SetFetchMode("orders", FetchMode.Join)
				.List();
			Assert.AreEqual(1, salespersons.Count, "Incorrect salesperson count");
			Assert.AreEqual(1, ((Salesperson) salespersons[0]).Orders.Count, "Incorrect order count");

			log.Info("Criteria query against Product...");
			IList products = session.CreateCriteria(typeof(Product))
				.Add(Expression.Eq("StockNumber", 124))
				.List();
			Assert.AreEqual(1, products.Count, "Incorrect product count");

			session.Close();
			testData.Release();
		}
开发者ID:NikGovorov,项目名称:nhibernate-core,代码行数:34,代码来源:DynamicFilterTest.cs

示例13: HqlFilters

		public void HqlFilters()
		{
			//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
			// HQL test
			//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
			log.Info("Starting HQL filter tests");
			TestData testData = new TestData(this);
			testData.Prepare();

			ISession session = OpenSession();
			session.EnableFilter("region").SetParameter("region", "APAC");

			session.EnableFilter("effectiveDate")
				.SetParameter("asOfDate", testData.lastMonth);

			log.Info("HQL against Salesperson...");
			IList results = session.CreateQuery("select s from Salesperson as s left join fetch s.Orders").List();
			Assert.IsTrue(results.Count == 1, "Incorrect filtered HQL result count [" + results.Count + "]");
			Salesperson result = (Salesperson) results[0];
			Assert.IsTrue(result.Orders.Count == 1, "Incorrect collectionfilter count");

			log.Info("HQL against Product...");
			results = session.CreateQuery("from Product as p where p.StockNumber = ?").SetInt32(0, 124).List();
			Assert.IsTrue(results.Count == 1);

			session.Close();
			testData.Release();
		}
开发者ID:NikGovorov,项目名称:nhibernate-core,代码行数:28,代码来源:DynamicFilterTest.cs


注:本文中的TestData.Release方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。