我不想手动使第二级缓存无效(刷新)。我怎么能这样做?
答案 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);