I don't see a problem with your child referencing the parent with the parent
being a base class. As long as Stage is mapped, and it contains the
collection mapping for Estimates, then you're golden. From memory it'd be
something like this:public class StageMap : ClassMap<Stage>
{
Id(x=>x.Id).AsYourIdType().Etc();
WithTable("Stages");

Map(x=>x.StartingDate);
*
HasMany(x=>x.Estimates).AsSet/Bag/List/Map().Inverse().KeyColumnName("StageID").Cascade().AllDeleteOrphan();
*
}

And the estimate map would look something like:
public class EstimateMap: ClassMap<Estimate>
{
I don't see a problem with your child referencing the parent with the parent
being a base class. As long as Stage is mapped, and it contains the
collection mapping for Estimates, then you're golden. From memory it'd be
something like this:public class StageMap : ClassMap<Stage>
{
Id(x=>x.Id).AsYourIdType().Etc();
WithTable("YourTableName")

Map(x=> x.PerformancePeriod);
*References(x=>x.Stage).ColumnName("StageID").Cascade.SaveUpdate();*
}

I've bolded the sections you'd want to look at more closely

Are you having problems with a similar mapping? If so, could you post what
your mapping looks like?

On Tue, Jun 16, 2009 at 6:41 PM, Jon <[email protected]> wrote:

>
> Is there a way for a an item in a collection (a "many" in a one-to-
> many relationship) to reference a base class of it's containing object
> (the "one", so to speak =P)?  Here's a simplified example to
> demonstrate what I'm thinking:
>
>
> public abstract class Stage : Entity {
>  DateTime StartingDate { get; set; }
>  IList<Estimate> Estimates { get; private set; }
>  // ... and much much more ...
> }
> public class DesignStage : Stage { /* ... */ }
> public class ConstructionStage : Stage { /* ... */ }
>
> public class Estimate : Entity {
>  public int PerformancePeriod { get; set; }
>
>  // this is what it looks like now:
>  public DateTime CompletionDate(DateTime startingDate) {
>    return startingDate.AddDays(PerformancePeriod);
>  }
>
>  // and this is what I'm hoping for:
>  public Stage Stage { get; set; }
>  public DateTime CompletionDate() {
>    return Stage.StartingDate.addDays(PerformancePeriod);
>  }
> }
>
>
> Do I need to create DesignEstimate and ConstructionEstimate classes
> for something like this to work? e.g.
>
> public abstract class Estimate : Entity
> {
>  public int PerformancePeriod { get; set; }
>  protected abstract Stage Stage { get; }
>  public DateTime CompletionDate()
>  {
>    return Stage.StartingDate.AddDays(PerformancePeriod);
>  }
> }
> public class DesignEstimate : Estimate
> {
>  public DesignStage Stage { get; set; }
> }
> public class ConstructionEstimate : Estimate
> {
>  public ConstructionStage Stage { get; set; }
> }
>
>
> Any ideas would be greatly appreciated.  Thanks.
>
> Jon
> >
>


-- 
- Hudson
http://www.bestguesstheory.com
http://twitter.com/HudsonAkridge

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" 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/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to