Is there a way to automap a ManyToMany collection on a subclass?

zulkamal's Avatar

zulkamal

19 Jul, 2010 02:24 PM via web

Hi, I have an abstract class Publishable that has a tags collection. A Review object inherits from the baseclass:
Publishable is set as IgnoreBase<Publishable>. I'm also using S#arp Architecture so Publishable and Tag inherits from S#arp's Entity

public abstract class Publishable : Entity, IPublishable
{
    public virtual IList<Tag> Tags { get; set; }
}

public class Tag : Entity
{
    public virtual string Name { get; set; }
    public virtual IList<Review> Reviews { get; set; }

    public Tag()
    {
        Reviews = new List<Review>();
    }
}

public class Review : Publishable
{
    public virtual string SomeField { get; set; }

    public Review()
    {
    }
}

When persisting a new Review, tags are not created (because tags collection are mapped to Publishable and not Reviews).

I can solve this by creating an override map for Review for the Tags collection. Is there an alternative way to this without creating an override map?

    Reply to this discussion

    Preview Comments are parsed with Markdown. Help with syntax

    Attached Files

      You can attach files up to 10MB

      What comes next? 'Monday Tuesday Wednesday ?????'