开发者

Nhibernate question about extension object without changing the original mapping

Say i have a cms with only one object called Article (for the sake of this example) with an ID and a title. This CMS implementation becomes part of a framework and is used as a library: e.g. CMSFactory.CMS.SaveArticle(a开发者_如何转开发);

The problem is that depending on the project requirements an article object may have more fields such as SomeDate. Is there any way to declare this relationship and still save an article with all its extra (project-dependent) fields without changing the base CMS library (but able to declare new mappings or so)?


You could create a subclass of Article with the specific fields for the project:

class SpecialArticleForThisProject: Article {
  public DateTime SomeDate {get;set;}
}

And map SpecialArticleForThisProject using one of the three inheritance mapping strategies.

The base CMS library wouldn't require any changes.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜