我是NHibernate的新手,刚刚开始。
我有一个非常简单的表包含Id(Int主键和自动递增),Name(varchar(100)),Description(varchar(100))
这是我的XML
<class name="DevelopmentStep" table="DevelopmentSteps" lazy="true">
<id name="Id" type="Int32" column="Id">
</id>
<property name="Name" column="Name" type="String" length="100" not-null="false"/>
<property name="Description" column="Description" type="String" length="100" not-null="false"/>
这是我想要获得所有记录的方式
public List<DevelopmentStep> getDevelopmentSteps()
{
List<DevelopmentStep> developmentStep;
developmentStep = Repository.FindAll<DevelopmentStep>(new OrderBy("Name", Order.Asc));
return developmentStep;
}
但我得到例外
The element 'id' in namespace 'urn:nhibernate-mapping-2.2' has incomplete content. List
of possible elements expected: 'urn:nhibernate-mapping-2.2:meta urn:nhibernate-mapping-
2.2:column urn:nhibernate-mapping-2.2:generator'.
请告诉我---谢谢
答案 0 :(得分:4)
您需要在映射中指定id的生成器类型:
<id name="Id" type="Int32" column="Id">
<generator class="native" />
</id>