Paul
Paul

Reputation: 1455

Help with strange relationship

I have an object called "Comment" now a Comment can be associated with a "News" article OR a "Feature" article or a "Product". So will look something like:

public class Comment
{
[BelongsTo]
public Feature Feature
{get;set;}

[BelongsTo]
public News News
{get;set;}

[BelongsTo]
public Product Product
{get;set;}
}

Now obviously only 1 Feautre, Product, or News will be populated at a time, and all implement interface "IContent". So how do I get one property like:

[BelongsTo(Type = Change type at runtime!!)]
public IContent Content
{get;set;}

Any idea how to structure this?

Upvotes: 1

Views: 74

Answers (1)

Mauricio Scheffer
Mauricio Scheffer

Reputation: 99730

Use [Any]. Docs about this here and here.

Upvotes: 2

Related Questions