我有下表:
Customers:
ID int PK
FirstName varchar(50)
LastName varchar(50)
我的映射文件:Customer.hbm.xml
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="Viper.DataAccess"
namespace="DataAccess">
<class name="Customer" entity-name="Customers" dynamic-update="true" >
<id name="ID">
<generator class="native" />
</id>
<property name="FirstName" />
<property name="LastName" />
</class>
</hibernate-mapping>
代码片段:
using (ISession session = sessionFactory.OpenSession())
{
var query = from customer in session.QueryOver<Customer>()
select customer;
var c = query.Take(1).SingleOrDefault<Customer>();
}
我收到“无法解析属性:来自:客户”的错误
任何想法为什么这会给我这个错误?
编辑:
我将查询修改为:
var query = from customer in session.QueryOver<Customer>()
where customer.ID >= 0
select customer;
它工作正常。
请告诉我,我不必为了让 NHibernate 工作而使用无意义的 where 子句!??