user216799
user216799

Reputation: 111

Fluent NHibernate mapping discriminator

I need to set more than one discriminate values for parent class. Is it possible to do and how?

For example:

PARENT_CLASS

DiscriminateSubClassesOnColumn("COLUMN_NAME", "X");

CHILD_CLASS_1

DiscriminatorValue("Y");

CHILD_CLASS_2

DiscriminatorValue("Z");

This is possible. But what if i have more than these 3 values in column "COLUMN_NAME"?

For example, if "P" and "Q" are also possible values for that column, what should I write?

DiscriminateSubClassesOnColumn("COLUMN_NAME", "X","P","Q"); Obviously this is not possible to write. But I don't know how to do this.

Upvotes: 1

Views: 819

Answers (1)

Firo
Firo

Reputation: 30803

the syntax for the CASE may vary for different sql databases

DiscriminateSubClassesOnColumn("").Formula("CASE COLUMN_NAME WHEN 'P' THEN 'X' WHEN 'Q' THEN 'X'  DEFAULT COLUMN_NAME");

Upvotes: 4

Related Questions