Castle ActiveRecord 视图错误:生成的密钥的 NHibernate.PropertyNotFoundException
我正在使用 ActiveRecord 映射视图,这意味着我需要一个主键。我没有,所以我使用 ROW_NUMBER() 在视图定义中创建一个来安抚系统。但是,我似乎不知道如何正确映射它。我得到:
在“blah_blah”类中找不到字段“stupidID” NHibernate.PropertyNotFoundException:无法在“blah_blah”类中找到字段“stupidID”
我的映射如下所示。没有
public long? stupidID;
[PrimaryKey("StupidId", Access = PropertyAccess.NosetterLowercaseUnderscore)]
public long? StupidId
{
get { return stupidID; }
}
人能看到我错过了什么吗?
I'm mapping a view using ActiveRecord, which means I need a primary key. I don't have one, so 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
NosetterLowercaseUnderscore
表示按照惯例,使用前缀“_”且为小写,因此该字段应称为_stupidid
而不是stupidID
。此外,PK 不应该是可以为 null 的类型。我会使用
long
而不是long?
NosetterLowercaseUnderscore
means that by convention a prefix '_' is used and it's lowercase, so the field should be called_stupidid
instead ofstupidID
.Also, the PK shouldn't be a nullable type. I'd use
long
instead oflong?