i'm trying to work with second level cache this is my fluent mapping
class AutoMapping
{
private ISessionFactory m_SessionFactory;
private ISession m_Session;
private IDbConnection conn;
public ISession configure()
{
return m_SessionFactory.OpenSession(conn);
}
public AutoMapping()
{
Configuration config = GetConfig();
m_SessionFactory = config.BuildSessionFactory();
m_Session = m_SessionFactory.OpenSession();
new SchemaExport(config).Execute(true, true, false, m_Session.Connection, Console.Out);
conn = m_Session.Connection;
}
private Configuration GetConfig()
{
var conf = Fluently.Configure();
Mappings(conf).DBSetup(conf);
return conf.BuildConfiguration();
}
private AutoMapping Mappings(FluentConfiguration configuration)
{
configuration.
Mappings(m => m.AutoMappings.Add(AutoMap.AssemblyOf<Chen>().Alterations(x=>x.Add(new CacheAlternation()))));
return this;
}
private AutoMapping DBSetup(FluentConfiguration configuration)
{
configuration.Database(SQLiteConfiguration.Standard.InMemory().ShowSql().
Cache(x => x.ProviderClass<NHibernate.Cache.HashtableCacheProvider>()));
return this;
}
}
public class CacheAlternation : IAutoMappingAlteration
{
#region IAutoMappingAlteration Members
public void Alter(AutoPersistenceModel model)
{
model.Conventions.Add(new CacheConvention());
}
#endregion
}
public class CacheConvention : FluentNHibernate.Conventions.IClassConvention
{
#region Implementation of IConvention<IMapInspector,IMapInstance>
public void Apply(IMapInstance instance)
{
}
#endregion
#region Implementation of IConvention<IClassInspector,IClassInstance>
public void Apply(IClassInstance instance)
{
instance.Cache.ReadWrite();
instance.Cache.Region(instance.EntityType.Name);
instance.Cache.IncludeAll();
}
#endregion
}
}
its not working i add some Chen's to db, than i select them and the sql is shown in console? what's wrong?