You can't currently do that. It's something we're planning on supporting,
but it isn't done yet.
I'm not in a position to show code right now, but I'm sure you could hack
something together in the meantime using reflection.

On Mon, Mar 9, 2009 at 2:54 PM, Eric Liprandi <eric.lipra...@gmail.com>wrote:

>
> Hi,
>
> I have been looking for the proper way of creating a subclass where
> the subclassing is specified in the child class. I do understand all
> the DiscrimanationSubClassOnColumn<T>(string) examples, but it has the
> major limitation that all subclasses have to be known up-front and
> detailed in the base class. We are considering using Fluent NHibernate
> in a project where other teams may be writing their own
> implementations of a particular base class and we would like to all
> them to extend the mapping on their own. So far, we are doing that
> using the "extends" XML mapping.
> WIth the power of Fluent NHibernate, we would like to replace those
> XML mappings with Fluent Mappings. At this time, we are not interested
> in Auto Mappings.
> I am going to try to put it in an example and see if it makes sense:
>
> public abstract class Task
> {
>    public int Id {get; set;}
>    public Guid Uid {get; set;}
>    ...
> }
>
> public class MyTask : Task
> {
>    public string MyField {get; set;}
>    public int MySecondField {get; set;}
> }
>
> public class TheirTask : Task
> {
>    public float TheirField {get; set;}
> }
>
> The mapping starts like that:
>
> public class TaskMap : ClassMap<Task>
> {
>    public TaskMap()
>    {
>        Id(x=>x.Id);
>        Map(x=>x.Uid);
>        ...
>        DiscriminateSubClassesOnColumn<string>("TaskType");
>    }
> }
>
> So far, so good, right?
>
> Now, how do I express something like:
>
> public MyTaskMap : SubClass<Task, MyTask>
> {
>    public MyTaskMap()
>    {
>         Map(x=>x.MyField);
>         Map(x=>x.MySecondField );
>    }
> }
>
> I have seen examples with the use of SubClassPart<,,> but they require
> a call to AddPart() from the base class map to all the subclasses and
> I am not sure what to build for the Discriminator<,>... I guess this
> could be a solution if we could register our Subclass maps with our
> system (using attributes for example) and then have code in the base-
> class map that iterates through all those... but it seems that we are
> so close with standard Fluent NHibernate that it feels like a hack to
> do it this way.
> I should also mention that we probably would be looking more at Joined
> Sub-classes as those custom tasks could have their own set of
> attributes.
>
> Thanks in advance for any pointer and maybe I'll get my hands dirty
> and try to implement that in the Fluent Code... (I am trying to scare
> you in helping me ;-)
>
> Regards,
>
> Eric.
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibernate@googlegroups.com
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to