I'd recommend letting the Photo, Video or Post handle the relation and 
then use many-to-many.

John Rayner wrote:
> How do you expect to store this in the database anyway?  Do you plan
> on a Comment table with a TargetID column which could contain a
> PhotoID / VideoID / PostID?  In this case you've got no referential
> integrity at all and clearly there's no way that NHib could work out
> which entity to load.
>
> I'd suggest having separate columns on your Comment table for PhotoID,
> VideoID and PostID.  And these could then be mapped as many-to-ones in
> your Comment class.  If you really want to, you can then have:
>
>    public ICommentable Target
>    {
>       get { return Photo ?? Video ?? Post; }
>    }
>
> Cheers,
> John
>
> On Sep 2, 6:28 pm, nyankov <[email protected]> wrote:
>   
>> Hi Everyone,
>>
>> I need help in following.
>>
>> Let's consider we have classes Photo, Video, Post, and each of this
>> classes implements ICommentable.
>>
>> public interface ICommentable{
>>    IList<Comment> Comments { get; set; }
>>
>> }
>>
>> public class Comment{
>>
>>     public ICommentable Target { get; set; }
>>
>> }
>>
>> My question is how should I map this situation. ManyToOne  and
>> OneToMany seems not work here because Photo, Video, Post are
>> different
>> classes and in Comment table should be able some how to mention which
>> is target.
>>
>> Any help will be much appriciated.
>>
>> Thanks.
>>     
> >
>
>   


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to