Using answer from this question, I'm trying to map my database view. But, it throw exception because I don't define any PrimaryKey
on the mapping class (the view doesn't have any primary key). Do I need to use CompositeKey
(this is not recommended, according to castle website) to solve this problem ? Or there is better solution ?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Quoting the docs:
Regular ActiveRecord types must have a primary key, a key that uniquely indentifies any row in a table. Single surrogate keys are favouvered over composite keys, but both are supported. When having control over the database schema, adding a surrogate primary key to the tables is the recommended way of implementing primary keys.
So add a simple primary key. If you can't, add a composite key.