如何使用流利的 nhibernate 在 Visual Studio 控制台中显示 SQL?
How to show SQL in Visual Studio console using fluent nhibernate?
我试图在 Visual Studio 的控制台中显示 SQL,但它不起作用。我正在使用带有以下代码的 fluent nhibernate:
string connectionString = WebCondStaClara.Lib.ConfigDB.StringConexao;
ISessionFactory sessionFactory = Fluently.Configure()
.Database(
MySQLConfiguration.Standard.ConnectionString(connectionString).ShowSql
)
.Mappings(m =>
m.FluentMappings
.AddFromAssemblyOf<Person>()
.AddFromAssemblyOf<Home>()
)
.ExposeConfiguration(cfg => new SchemaExport(cfg)
.Create(true, false)).BuildSessionFactory();
return sessionFactory.OpenSession();
我做错了什么?
(Fluent)NHibernate 使用 log4net 提供日志记录支持。您必须适当地配置 log4net(使用控制台、调试或跟踪附加程序构建配置,并让记录器使用这些附加程序)。
看看这里:
How to log SQL calls with NHibernate to the console of Visual Studio?
我试图在 Visual Studio 的控制台中显示 SQL,但它不起作用。我正在使用带有以下代码的 fluent nhibernate:
string connectionString = WebCondStaClara.Lib.ConfigDB.StringConexao;
ISessionFactory sessionFactory = Fluently.Configure()
.Database(
MySQLConfiguration.Standard.ConnectionString(connectionString).ShowSql
)
.Mappings(m =>
m.FluentMappings
.AddFromAssemblyOf<Person>()
.AddFromAssemblyOf<Home>()
)
.ExposeConfiguration(cfg => new SchemaExport(cfg)
.Create(true, false)).BuildSessionFactory();
return sessionFactory.OpenSession();
我做错了什么?
(Fluent)NHibernate 使用 log4net 提供日志记录支持。您必须适当地配置 log4net(使用控制台、调试或跟踪附加程序构建配置,并让记录器使用这些附加程序)。
看看这里: How to log SQL calls with NHibernate to the console of Visual Studio?