0

我希望 nHibernate 在我的日志中给我一个干净的查询。而不是这样的单行:

select project2x0_.proj_id as proj1_10_0_, projwbs1_.wbs_id as wbs1_11_1_, project2x0_.proj_short_name as proj2_10_0_, project2x0_.project_flag as project3_10_0_, projwbs1_.wbs_name as wbs2_11_1_, projwbs1_.wbs_short_name as wbs3_11_1_, projwbs1_.proj_id as proj4_11_1_, projwbs1_.proj_id as proj4_0__, projwbs1_.wbs_id as wbs1_0__ from project project2x0_ left outer join projwbs projwbs1_ on project2x0_.proj_id=projwbs1_.proj_id where @p0=1;@p0 = True [Type: Boolean (0)]

我更希望以更易读的形式看到它,例如:

select project2x0_.proj_id as proj1_10_0_
, projwbs1_.wbs_id as wbs1_11_1_
, project2x0_.proj_short_name as proj2_10_0_
, project2x0_.project_flag as project3_10_0_
, projwbs1_.wbs_name as wbs2_11_1_
, projwbs1_.wbs_short_name as wbs3_11_1_
, projwbs1_.proj_id as proj4_11_1_
, projwbs1_.proj_id as proj4_0__
, projwbs1_.wbs_id as wbs1_0__ 
from project project2x0_ 
left outer join projwbs projwbs1_
  on project2x0_.proj_id=projwbs1_.proj_id 
where @p0=1;

;@p0 = True [类型:布尔值 (0)]

特定字段可以都在一行上,这很好。但我真的很喜欢看到将 FROM、JOIN 和 WHERE 语句拉出来。

我希望它出现在 log4net 输出中,而不是通过某些 3rd 方工具。

有任何想法吗?

4

1 回答 1

0

在 Configuration 对象上将“format_sql”属性设置为 true 会产生与您想要的类似的输出。

于 2012-09-09T19:27:04.320 回答