Nhibernate show_sql=false不工作
这是我如何使用Fluent Nhibernate创建会话工厂的Nhibernate show_sql=false不工作,nhibernate,fluent-nhibernate,log4net,Nhibernate,Fluent Nhibernate,Log4net,这是我如何使用Fluent Nhibernate创建会话工厂的 public static ISessionFactory CreateSessionFactory() { FluentNHibernate.Cfg.FluentConfiguration fconfig; fconfig = FluentNHibernate.Cfg.Fluently.Configure()
public static ISessionFactory CreateSessionFactory()
{
FluentNHibernate.Cfg.FluentConfiguration fconfig;
fconfig = FluentNHibernate.Cfg.Fluently.Configure()
.Cache(c=>c.UseQueryCache())
.Database(FluentNHibernate.Cfg.Db.MsSqlConfiguration.MsSql2008
.ConnectionString(c => c.FromConnectionStringWithKey("Database"))
.ProxyFactoryFactory<NHibernate.ByteCode.LinFu.ProxyFactoryFactory>()
.Mappings(
m => m.FluentMappings
.AddFromAssemblyOf<NHibernateRepositoryRegistry>()
.Conventions.Add<Conventions.PrimaryKeyConvention>()
.Conventions.Add<Conventions.IdForeignKeyConvention>()
.Conventions.Add<Conventions.ReferenceForeignKeyConstraintNameConvention>()
)
// i have tried this but it did not work
//.ExposeConfiguration(config=>{config.SetProperty("show_sql", "false");});
return fconfig.BuildSessionFactory();
}
也试过
.ExposeConfiguration(config=>{config.SetProperty("hibernate.show_sql", "false");});
但我仍然在nhibernatesql.log文件中生成sql
我使用的是NHibernate v3.1.0.4000和FluentNHibernate v1.2.0.712以及ASP.NET MVC3
有人知道为什么sql仍在生成吗
show_sql或ShowSql()是否仅用于Console.output目的,sql是否被发送到log4net
我主要担心的是,如果ShowSQL设置为true,性能会变慢
不确定我是否在其他地方设置了ShowSql好的,我想我得到了答案 基于 show_sql仅用于Console.out目的,sql将被发送到log4net。。这就是为什么我在日志中看到sql
.ExposeConfiguration(config=>{config.SetProperty("show_sql", "false");});
.ExposeConfiguration(config=>{config.SetProperty("hibernate.show_sql", "false");});