Re: Table Per Type

18 views
Skip to first unread message

Rasmoo

unread,
Jul 10, 2012, 12:29:42 PM7/10/12
to fluent-n...@googlegroups.com
Either
In your Promote-Person-to-SubscriberPerson process
Delete/retire the original person, and create the new SubscriberPerson
Or
User a different model, such as Person Subscribes-To-Something (Has-a-subscription)

On Tuesday, July 10, 2012 5:52:34 PM UTC+2, par anon wrote:
I have a mapping question related to Table Per Type. I have following hierarchy:

-   Person (maps to table person)
-   A person can be a Subscriber (maps to table Subscriber)
-   A person can be a Service Provider (maps to table ServiceProvider)
-   A person can be {other things}
 


This maps to respective domain objects. The current mapping looks something like below:
public class PersonMapping : ClassMap<Models.Person>
{
        public PersonMapping()
        {
            Table("Person");
            Id(p => p.Id);
   ... other props
}
}

public class SubscriberMapping : SubclassMap<Models.Subscriber>
{
  public SubscriberMapping()
        {
            Table("Subscriber");
            KeyColumn("Id")
            ... other props
        }

}

public class ProviderMapping : SubclassMap<Models.Provider>
{
        public ProviderMapping()
        {
            Table("ServiceProvider");
            KeyColumn("Id");
   ... other props
}
}


The problem I am facing is when a person exists but not as a Subscriber. 

The behavior that we are trying to implement is:

Add Subscriber:
 - Check if Person exists by <well defined criteria>
 - If Person was found insert into subscriber table 
 - If Person was not found 
      - Create Person
      - Insert into subscriber table

Can this behavior be achieved using mapping?

Thanks,
PG
 
        
Reply all
Reply to author
Forward
0 new messages