开发者

NHibernate Inheritance - Discriminator-Value

Is it possible to have a discriminator that works like this with NHibernate?

If the value equals String.Empty --> Class1 Else --> Class2

I already have a string column for CultureName and I would like to use it as a discriminator. I don't want to add an extra boolean column. If the CultureName is String.Empty then I would like to one class, else another one.

If it is not possible, could you help me find a way to do this.

I'm using xml mappings (not Fluent NHibernate).

What I'm searching fo开发者_运维问答r is something like a wildcard for the else (default) case so I can map like this :

<subclass name="Class1" discriminator-value="">
<subclass name="Class2" discriminator-value="*">


You can add a discriminator forumla to the primary class

<discriminator formula="case when discriminatorID = '' then 1 else 2 end"/>

then

<subclass name="Class1" discriminator-value="1">

<subclass name="Class2" discriminator-value="2">


you should check out the table-heirarchy mapping strategy specified here which specifies how you can use a discriminator column for your class mappings.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜