I don't like disposing session because it breaks session-per-request strategy in my app.
So i have created dirty hack to solve my need:
Code:
private static FieldInfo transaction = null;
public static void ClearSessionTransaction()
{
if (transaction == null)
{
Assembly nhib = Assembly.Load("NHibernate");
foreach (Type type in nhib.GetTypes())
if (type.FullName == "NHibernate.Impl.SessionImpl")
{
transaction = type.GetField("transaction", BindingFlags.NonPublic | BindingFlags.Instance);
break;
}
}
transaction.SetValue(DefaultSession, null);
}
PS I don't recomend this way, but it best for me.