开发者

NHibernate: Discriminators without inheritance

I have the following model:

public class Some开发者_Go百科Object1 {
  public virtual Guid Id {get; set; }
  public string Property1 {get; set; }
}
public class SomeObject2 {
  public virtual Guid Id {get; set; }
  public string Property2 {get; set;}
}

and the table

SOME_OBJECTS 
  PK_SOME_OBJECTS Guid
  WHICH_OBJECT Integer
  PROPERTY1 varchar2
  PROPERTY2 varchar2

when the WHICH_OBJECT column = 1 the row contains information for SomeObject1, when the WHICH_OBJECT column = 2 the row contains information for SomeObject2.

How would I go about doing these mappings? I've found the discriminator feature but it seems to only apply when you have subclasses in an inheritance hierarchy.


I'm pretty sure it's not possible to map two unrelated entities to the same table; however, you may be able to map them to two different views that reference the same table.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜