How to configure Fluent NHibernate to output queries to Trace or Debug instead of Console?

前端 未结 3 1834
Happy的楠姐
Happy的楠姐 2020-12-07 11:16

How to configure Fluent NHibernate to output queries to Trace or Debug instead of Console? I\'m using MsSqlConfiguration.MsSql2008.ShowSql() but it has no param

3条回答
  •  天命终不由人
    2020-12-07 11:55

    I have not tried this with SQL Server, but with SQLite, the following code will show generated SQL in the Output window (Debug menu -> Windows -> Output, in VS2008).

    The "Show output from:" combo box in the Output window should be set to "Debug" - VS2008 did that for me automatically.

                sessionFactory = Fluently.Configure()
                    .Database(SQLiteConfiguration.Standard
                                .UsingFile(DbFile)
                                // Display generated SQL in Output window
                                .ShowSql()
                              )
                    .Mappings(m => m.AutoMappings.Add( GetAutoPersistenceModel() ))
                    .BuildSessionFactory()
                    ;
    

    A word of warning - turning this on can slow down execution considerably.

提交回复
热议问题