开发者

Exception when retrieving record using Nhibernate

I am new to NHibernate and have just started right now.

I have very simple table contain Id(Int primary key and auto incremented), Name(varchar(100)), Description(varchar(100))

Here is my 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"/>

here is how I want to get all the record

 public List<DevelopmentStep> getDevelopmentSteps()
   {
       List<De开发者_运维问答velopmentStep> developmentStep;
       developmentStep = Repository.FindAll<DevelopmentStep>(new OrderBy("Name", Order.Asc));
       return developmentStep;
   } 

But I am getting exception

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'.

Please Advise me --- Thanks


You need to specify the generator type of the id in your mapping:

<id name="Id" type="Int32" column="Id">
    <generator class="native" />
</id>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜