开发者

Castle ActiveRecord Error With View: NHibernate.PropertyNotFoundException for generated key

I'm mapping a view using ActiveRecord, which means I need a primary key. I don't have one, so开发者_JS百科 I'm using ROW_NUMBER() to create one in the view definition to placate the system. However, I don't seem to know how to map it properly. I'm getting:

Could not find field 'stupidID' in class 'blah_blah' NHibernate.PropertyNotFoundException: Could not find field 'stupidID' in class 'blah_blah'

My mapping looks like this. There is no

    public long? stupidID;
    [PrimaryKey("StupidId", Access = PropertyAccess.NosetterLowercaseUnderscore)]
    public long? StupidId
    {
      get { return stupidID; }
    }

Can anyone see what I'm missing?


NosetterLowercaseUnderscore means that by convention a prefix '_' is used and it's lowercase, so the field should be called _stupidid instead of stupidID.

Also, the PK shouldn't be a nullable type. I'd use long instead of long?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜