|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate;
using NHibernate.Burrow;
using Domain;
namespace Tests
{
/// <summary>
/// NHibernate helper class. Intended for SessionFactory and Session management
/// helper functionality.
/// </summary>
public static class NHibernateHelper
{
public static void EvictSecondLevelCache()
{
BurrowFramework bf = new BurrowFramework();
ISessionFactory sFactory = bf.GetSessionFactory(typeof(Parent));
sFactory.EvictQueries();
IDictionary classMetadata = sFactory.GetAllClassMetadata();
foreach (Type t in classMetadata.Keys)
{
sFactory.Evict(t);
}
IDictionary collectionMetadata = sFactory.GetAllCollectionMetadata();
foreach (string role in collectionMetadata.Keys)
{
sFactory.EvictCollection(role);
}
}
public static void EvictSecondLevelQueryCache(string region)
{
BurrowFramework bf = new BurrowFramework();
ISessionFactory sFactory = bf.GetSessionFactory(typeof(Parent));
if (String.IsNullOrEmpty(region))
sFactory.EvictQueries();
else
sFactory.EvictQueries(region);
}
public static void EvictSecondLevelQueryCache()
{
EvictSecondLevelQueryCache(String.Empty);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.