问题是从hql到sql语句中,配置文件已经配置,本来应该用[]括起来sql关键字,但是却没有括起来。
配置
<set name="Orders" table="'Order'" generic="true" inverse="true">
      <key column="CustomerId" foreign-key="fk_customer" /><!--这里写的是字表对应主表的外键-->
      <one-to-many class="Model.Order,Model"/>
    </set>生成的sql语句
select distinct customer0_.CustomerId as CustomerId0_, customer0_.Firstname as Firstname0_, customer0_.Lastname as Lastname0_ 
from Customer customer0_ inner join Order orders1_ on customer0_.CustomerId=orders1_.CustomerId 
where (orders1_.Date>@p0 ); @p0 = '2009/2/3 0:00:00'

解决方案 »

  1.   

    解决了
    帮助文档上说 
    You may force NHibernate to quote an identifier in the generated SQL by enclosing the table or column name in backticks in the mapping document.NHibernate will use the correct quotation stylefor the SQL Dialect (usually double quotes, but brackets for SQL Server and backticks for MySQL). 
    但是明显没有达到相应的效果。所以我自己加上了方括号。