thanks, I am going to remodel my domain.

On Aug 6, 8:04 pm, Jason Meckley <[email protected]> wrote:
> @Luka: i think you are confusing the English grammar with OO grammar.
> when people talk about their job they say "I'm Jason I am a
> programmer". I could say "I am a father", "I am a brewer", "I am a
> friend". These statements make sense when people talk to one another.
> In actuality I am not any of those things, I'm just a person. The
> statements I made where aspects about my life that describe me as a
> person.  Take any of those away and I'm still a person.
> So rather than -------> I should say
> I am a programmer -------> My job is a programmer
> I am a father -------> have children
> I am a brewer -------> I like to brew beer as a hobby
> I am a friend -------> I have friends
>
> these statements translate better to OOP
> a person has jobs
> a person has children
> a person has hobbies
> a person has friends
>
> which translates to code as
> class Person
> {
>     Job CurrentOccupation
>     List<Job> Jobs
>     List<Person> Children
>     List<Hobby> Hobbies
>     List<Person> Friends
>
> }
>
> jobs may use a hierarchy. A teacher is a job and policeman is a job.
> in that case it may look like
> class Teacher : Job
> {
>    School
>    Class
>    Grade}
>
> class PoliceMan : Job
> {
>    Badge Number
>    Unit
>
> }
>
> this is where an inheritance strategy would come into play.
>
> On Aug 6, 1:38 pm, Diego Mijelshon <[email protected]> wrote:
>
>
>
> > To formalize it, a person *has many* roles.
>
> >     Diego
>
> > On Fri, Aug 6, 2010 at 14:35, Jason Dentler <[email protected]> wrote:
> > > You could do this:
>
> > > public class Client : Entity
> > > {
>
> > > public Person Person { get; protected set; }
>
> > > }
>
> > > public class Employee : Entity
> > > {
>
> > > public Person Person { get; protected set; }
>
> > > }
>
> > > public class Person : Entity
> > > {
> > > }
>
> > > On Fri, Aug 6, 2010 at 12:30 PM, Luka <[email protected]> wrote:
>
> > >> Yes I know that a Dog is not a Cat.
> > >> Let say I add another type that inherits Person:
> > >> public class Client: Person{...}
> > >> or
> > >> public class Employee:Person{...}
>
> > >> So I have a Person that is an employee in a company, but the same
> > >> person is a client in the same company he is working for.
>
> > >> How to model this type o relation?
>
> > >> On Aug 6, 6:57 pm, Fabio Maulo <[email protected]> wrote:
> > >> > That is not a classic table-per-subclass.
> > >> > As said that is a misunderstanding of OOP.
> > >> > A Dog can be a Cat.
>
> > >> > In you case a Person can assume more than one roles (as usual when you
> > >> work
> > >> > with a class named Person)
>
> > >> > On Fri, Aug 6, 2010 at 1:37 PM, Luka <[email protected]> wrote:
> > >> > > I see the point, but how to solve this? Because this is the classic
> > >> > > Table per subclass and NHibernate is supposed to support this type of
> > >> > > inheritance. (by the book NHibernate in action)
>
> > >> > > On Aug 6, 6:16 pm, Fabio Maulo <[email protected]> wrote:
> > >> > > > The problem is not the mapping but the concept of OOP.
> > >> > > > Let me show another case:
> > >> > > > Animal
> > >> > > > Dog : Animal
> > >> > > > Cat : Animal
>
> > >> > > > In the DB I have an Animal with ID 1 that is a Dog and a Cat.
>
> > >> > > > On Fri, Aug 6, 2010 at 11:50 AM, James Gregory <
> > >> [email protected]
> > >> > > >wrote:
>
> > >> > > > > Please show us your mappings.
>
> > >> > > > > You should have:
>
> > >> > > > > ClassMap<Person>
> > >> > > > > SubclassMap<Teacher>
> > >> > > > > SubclassMap<Policeman>
>
> > >> > > > > On Aug 6, 3:32 pm, Luka <[email protected]> wrote:
> > >> > > > > > ups my error!
>
> > >> > > > > > I have this problem:
> > >> > > > > > public class Person:DomainBase<Person,int>
> > >> > > > > > {
> > >> > > > > >    public string Name;
>
> > >> > > > > > }
>
> > >> > > > > > public class Teacher: Person
> > >> > > > > > {...
>
> > >> > > > > > }
>
> > >> > > > > > public class Policeman:Person
> > >> > > > > > {...
>
> > >> > > > > > }
>
> > >> > > > > > All classes are mapped using fluent nhibernate.
> > >> > > > > > The inheritance is mapped by: SubClassMap<Person>.
>
> > >> > > > > > In code I am doing this:
> > >> > > > > > IPersonRepository rep =
> > >> > > > > > ObjectFactory.GetInstance<IPersonRepository>();
> > >> > > > > > var teachers = rep.GetAllTeachers();
> > >> > > > > > var policemans = rep.GetAllPolicemans();
>
> > >> > > > > > The error I am getting is this:
>
> > >> > > > > > Object with id: 1 was not of the specified subclass: Policeman
> > >> > > > > > (loading object was of wrong class [Teacher]).
>
> > >> > > > > > in the database I have i person with ID 1 that is a teacher and
> > >> a
> > >> > > > > > policeman.
>
> > >> > > > > > How to solve this problem?
>
> > >> > > > > --
> > >> > > > > You received this message because you are subscribed to the 
> > >> > > > > Google
> > >> > > Groups
> > >> > > > > "nhusers" group.
> > >> > > > > To post to this group, send email to [email protected].
> > >> > > > > To unsubscribe from this group, send email to
> > >> > > > > [email protected]<nhusers%[email protected]
> > >> > > > >  >
> > >> <nhusers%[email protected]<nhusers%252bunsubscr...@googlegroup
> > >>  s.com>>
> > >> > > <nhusers%[email protected]<nhusers%252bunsubscr...@googlegroup
> > >> > >  s.com>
> > >> <nhusers%252bunsubscr...@googlegroup s.com>>
> > >> > > > > .
> > >> > > > > For more options, visit this group at
> > >> > > > >http://groups.google.com/group/nhusers?hl=en.
>
> > >> > > > --
> > >> > > > Fabio Maulo
>
> > >> > > --
> > >> > > You received this message because you are subscribed to the Google
> > >> Groups
> > >> > > "nhusers" group.
> > >> > > To post to this group, send email to [email protected].
> > >> > > To unsubscribe from this group, send email to
> > >> > > [email protected]<nhusers%[email protected]
> > >> > >  >
> > >> <nhusers%[email protected]<nhusers%252bunsubscr...@googlegroup
> > >>  s.com>>
> > >> > > .
> > >> > > For more options, visit this group at
> > >> > >http://groups.google.com/group/nhusers?hl=en.
>
> > >> > --
> > >> > Fabio Maulo
>
> > >> --
> > >> You received this message because you are subscribed to the Google Groups
> > >> "nhusers" group.
> > >> To post to this group, send email to [email protected].
> > >> To unsubscribe from this group, send email to
> > >> [email protected]<nhusers%[email protected]
> > >>  >
> > >> .
> > >> For more options, visit this group at
> > >>http://groups.google.com/group/nhusers?hl=en.
>
> > >  --
> > > You received this message because you are subscribed to the Google Groups
> > > "nhusers" group.
> > > To post to this group, send email to [email protected].
> > > To unsubscribe from this group, send email to
> > > [email protected]<nhusers%[email protected]
> > >  >
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/nhusers?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" 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/nhusers?hl=en.

Reply via email to