SQL corresponding to LINQ-queries are logged from the NHibernate.SQL logger
using the DEBUG priority level. They should also be visible from the
NHibernate.Loader.Loader logger, with priority level INFO (in this case
without parameter values).

This is independent of the show_sql setting, which only affects logging of
SQL statements to the console.

/Oskar



2014-01-27 Mirosław Sarna <[email protected]>

> Hi,
>
> My general question:
> *Could I see in log sql query which was generated by LINQ?*
>
>
> I have ling query:
>
> var q = (from u in s.Query<AppUser>()
>                                  where u.Name.EndsWith("AlaMoKota")
>                                  select u).ToList();
>
> I have option *show_sql = true*
> but I can find only this information in app log :
>
> 2014-01-27 15:28:42.0080 - 8/Domain-BB.AppCore.DbCommon.Tests.dll -
> NHibernate.Impl.SessionImpl -
> [session-id=31b3874b-dfaf-4fdf-81ab-91cfae013099] opened session at
> timestamp: 635264333220, for session factory:
> [/8987a802c98d4e68ac775f035e524e81]
> 2014-01-27 15:28:42.0236 - 8/Domain-BB.AppCore.DbCommon.Tests.dll -
> NHibernate.Impl.SessionImpl - setting cache mode to: Ignore
> 2014-01-27 15:28:42.0547 - 8/Domain-BB.AppCore.DbCommon.Tests.dll -
> NHibernate.Linq - Expression (partially evaluated): 
> *value(NHibernate.Linq.NhQueryable`1[ModelAV1.AppUser]).Where(u
> => u.Name.EndsWith("AlaMoKota")) *
> 2014-01-27 15:28:42.0720 - 8/Domain-BB.AppCore.DbCommon.Tests.dll -
> NHibernate.Engine.Query.QueryPlanCache - unable to locate HQL query plan in
> cache; generating
> (.Where[ModelAV1.AppUser](NHibernate.Linq.NhQueryable`1[ModelAV1.AppUser],
> Quote((u, ) => (u.Name.EndsWith(p1, ))), ))
> 2014-01-27 15:28:42.4867 - 8/Domain-BB.AppCore.DbCommon.Tests.dll -
> NHibernate.Engine.Query.QueryPlanCache - located HQL query plan in cache
> (.Where[ModelAV1.AppUser](NHibernate.Linq.NhQueryable`1[ModelAV1.AppUser],
> Quote((u, ) => (u.Name.EndsWith(p1, ))), ))
> 2014-01-27 15:28:42.4867 - 8/Domain-BB.AppCore.DbCommon.Tests.dll -
> NHibernate.Engine.Query.HQLQueryPlan - find:
> .Where[ModelAV1.AppUser](NHibernate.Linq.NhQueryable`1[ModelAV1.AppUser],
> Quote((u, ) => (u.Name.EndsWith(p1, ))), )
> 2014-01-27 15:28:42.4867 - 8/Domain-BB.AppCore.DbCommon.Tests.dll -
> NHibernate.Engine.QueryParameters - named parameters: {}
> 2014-01-27 15:28:42.4867 - 8/Domain-BB.AppCore.DbCommon.Tests.dll -
> NHibernate.AdoNet.ConnectionManager - after autocommit
> 2014-01-27 15:28:42.4867 - 8/Domain-BB.AppCore.DbCommon.Tests.dll -
> NHibernate.Impl.SessionImpl - transaction completion
>
> I can't find information about with SQL.
>
> *But in other places I could find e.g.:*
>
>
> 2014-01-27 15:28:41.3848 - 8/Domain-BB.AppCore.DbCommon.Tests.dll -
> NHibernate.SQL - -- Void
> BB.AppCore.DbCommon.Tests.TestsForDbCommon.T_InitializeSession()
> [File=TestsForDbCommon.cs, Line=61]
> --- BB.AppCore.DbCommon.BBSessionManager
> BB.AppCore.UnitTestCommon.TestTools.CreateSession(System.String[],
> InitDatabaseSettings) [File=TestTools.cs, Line=129]
> ---- Void BB.AppCore.DbCommon.BBSessionManager.PrepareStructure()
> [File=BBSessionManager.cs, Line=332]
> ----- BB.AppCore.DbCommon.StructureVersionStatus
> BB.AppCore.DbCommon.BBSessionManager.DoUpgrade() [File=BBSessionManager.cs,
> Line=514]
> ------ Void
> BB.AppCore.DbCommon.BBSessionManager.SaveVersionInfoInDB(BB.AppCore.DbCommon.MappAtr.IDbModuleInfo)
> [File=BBSessionManager.cs, Line=565]
> ------- Void BB.AppCore.DbCommon.Logging.NLogLogger.Debug(System.Object)
> [File=NLogFactory.cs, Line=163]
> -------- System.String
> BB.AppCore.DbCommon.Logging.NLogLogger.msgConverter(System.String)
> [File=NLogFactory.cs, Line=108]
>
> ----------------------------
> Batch commands:
>
>     UPDATE
>         ACDC_DB_MODULE_VERSION
>     SET
>         DB_MODULE_ID = 2
>     WHERE
>         ID = 2;
>     @p0 = 2 [Type: Int32 (0)], @p1 = 2 [Type: Int32 (0)]
>
>
> *For HQL is also working:*
>
> 2014-01-27 15:28:40.2811 - 8/Domain-BB.AppCore.DbCommon.Tests.dll -
> NHibernate.Hql.Ast.ANTLR.HqlSqlGenerator - SQL: select
> max(dbmoduleve0_.VERSION) as col_0_0_ from ACDC_DB_MODULE_VERSION
> dbmoduleve0_ where dbmoduleve0_.MODULE_NA
>
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/nhusers.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to