session.Evict 清除查询结果集的缓存
public TEntity FindSingleByExpression(Expression<Func<TEntity, bool>> expression)
{
var session = this.OpenSession();
// session.Clear(); //session.Evict(entity);有时会不起作用, session.Clear(); 反而可以代研究
var entity = session.Linq<TEntity>().FirstOrDefault(expression);
session.Evict(entity);
return entity;
}
public void Evict(TEntity entity)
{
using (var session = this.OpenSession())
{
session.Evict(entity);
}
}
session.Evict 清除查询结果集的缓存。