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
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---