views:

16

answers:

0

Hello!

I wonder about something. I'm sitting here with a solution there I have 1 superclass that has 2 subclasses and I'm currently mapping this using JoinedSubClass, but I get that this method is obsolete, and says that I should ClassMap and SubClassMap, but if I do this the AutoMapping does not work, and I don't want that. Is there any workaround for this?

Here's the hierarchy:

public class Tag : Entity
{

public virtual string Name {get;set;}
public virtual User User {get;set;}

}

public class RespondentTag : Tag
{
    public virtual IList<Respondent> Respondents {get;set;}
}


public class ArchiveTag : Tag
{
    public virtual IList<Survey> Surveys {get;set;}
}

As you probably figured out I want this to be a table per hierarchy-mapping with subclasses with lists that are Many-To-Many. Like a table 'Tag', then Tag_Respondent and Tag_Archive (for many-to-many relationship).

Here's the mapping that I'm currently using:

public class TagMap : IAutoMappingOverride<Tag>
{
  public void Override(AutoMapping<Tag> mapping)
  { 
     //This is obsolete
     mapping.JoinedSubClass("RespondentTagId", RespondentTagMap.AsJoinedSubClass());
     mapping.JoinedSubClass("ArchiveTagId", ArchiveTagMap.AsJoinedSubClass());

  }
}

public class RespondentTagMap
{
    public static Action<JoinedSubClassPart<RespondentTag>> AsJoinedSubClass()
    {
     return part =>

        part.HasManyToMany(x => x.RespondentList)
           .Cascade
           .SaveUpdate()
           .Inverse()
           .Table("Tag_Respondent");

    }
}


public class ArchiveTagMap
{
    public static Action<JoinedSubClassPart<ArchiveTag>> AsJoinedSubClass()
    {
     return part =>

        part.HasManyToMany(x => x.Surveys)
           .Cascade
           .SaveUpdate()
           .Inverse()
           .Table("Tag_Archive");

    }
}

Does anyone know about a workaround or another solution for solving this? (Without disabling automapping)

Any answers will be appreciated.

Thanks in advance!