简体   繁体   English

如何使用流畅的 nhibernate 在 Visual Studio 控制台中显示 SQL?

[英]How to show SQL in Visual Studio console using fluent nhibernate?

I'm trying to show the SQL in the console of Visual Studio but it doesn't work.我试图在 Visual Studio 的控制台中显示 SQL,但它不起作用。 I'm using fluent nhibernate with the following code:我正在使用 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();

What am I doing wrong?我究竟做错了什么?

(Fluent)NHibernate uses log4net to provide logging support. (Fluent)NHibernate 使用 log4net 提供日志记录支持。 You have to configure log4net appropriately (build up a configuration with a console, debug or trace appender and let the loggers use these appenders).您必须适当地配置 log4net(使用控制台、调试或跟踪附加程序构建配置,并让记录器使用这些附加程序)。

Have a look here: How to log SQL calls with NHibernate to the console of Visual Studio?看看这里: 如何使用 NHibernate 将 SQL 调用记录到 Visual Studio 的控制台?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM