删除Nhibernate日志记录中的别名详细信息

时间:2011-09-23 21:01:37

标签: nhibernate

当NHibernate记录其SQL时,它会为它检索的所有列使用别名,例如:

SELECT menuitems0_.menuSectionId as menuSect6_1_

我只是想知道是否可以省略别名信息以使SQL更清晰,例如

SELECT menuitems.menuSectionId

当我向其他人演示时,这会有很大帮助,因为向他们展示NHibernate在幕后做的事情会更容易。

由于

1 个答案:

答案 0 :(得分:2)

我不认为删除别名是可能的,但如果使用'FormatSql'选项,可以使输出看起来更好。配置会话工厂时将其设置为true

config.SetProperty(Environment.ConnectionString, "...")
config.SetProperty(Environment.ShowSql, "true")
config.SetProperty(Environment.FormatSql, "true")

所以输出看起来像这样:

SELECT
    this_.ID as ID58_0_,
    this_.Name as Name58_0_,
    ...
FROM
    MyTable this_ 
WHERE
    this_.Name = @p0;

或使用NHibernate Profiler进行演示。

相关问题