手动使NHibernate二级缓存无效

时间:2011-04-07 01:48:31

标签: nhibernate

我不想手动使第二级缓存无效(刷新)。我怎么能这样做?

1 个答案:

答案 0 :(得分:4)

您可以这样做:

SessionFactory.EvictQueries();
foreach (var collectionMetadata in this._SessionFactory.GetAllCollectionMetadata())
        SessionFactory.EvictCollection(collectionMetadata.Key);
foreach (var classMetadata in this._SessionFactory.GetAllClassMetadata())
        SessionFactory.EvictEntity(classMetadata.Key);