views:

52

answers:

0

Here are my classes:

public abstract class TypeBase  
{  
  public virtual int? Id { get; set; }  
  public virtual string Name { get; set; }  
}

// various other classes extend TypeBase the same way  
public class Color : TypeBase 
{  
}

public class Template  
{  
  public virtual int? Id { get; set; }  
  public virtual IList<Style> Style { get; set; }  
  public virtual string ThumbUrl { get; set; }  
  public virtual IList<Theme> Theme { get; set; }  
  public virtual decimal Price { get; set; }  
  public virtual int LayoutCount { get; set; }  
  public virtual string TemplateId { get; set; }  
  public virtual IList<Color> AvailableColors { get; set; }  
  public virtual IList<SubType> SubType { get; set; }  
  public virtual IList<Url> Urls { get; set; }  
}

public abstract class TemplateRelationalTable  
{  
  public virtual int Id { get; set; }  
  public virtual Template Template{get; set;}  
}

public class TemplateColor : TemplateRelationalTable  
{  
  public virtual Color Color { get; set; }  
}

My table TemplateColor has entries with an id, a TemplateId, and a ColorId, with the appropriate relationships set up in the database.

I have 3 entries in this table. Each obviously has it's own Id. TemplateId is 2 for all 3 of those records. ColorId is 1, 2, and 3 respectively. So template #2, should have 3 AvailableColors 1, 2, 3...

How do I map this with the automappings, so that my AvailableColors has the right values in it? I can do this with normal fluent easy enough, but the conventions are new for me.