And thank you in advance for your time.
We are using CSLA 3.5.1, however, eventually, there can not be much in the problem with CSLA.
My company has gone very far from the road of a normal modeling error and it is facing end. I have simplified the following domain objects to clarify the problem:
We have definition of 3 sections like:
Class person: BusinessBase < P> class student: person
class teacher: person
We are using NHibernate for our ORM, and students and teacher classes in our sub-sections of the person in our mapping Have joined (we have individuals, student and teacher tables), one Utpnn key as using PersonID.
The problem, as you can guess, now we have a situation where the student can also be a teacher under the current item and the data model, it causes a primary key violation, when We try to add a student who is already a teacher or vice-versa. Question one: Is there a CSLA magic that I can perform
if not ...
In researching this problem, I have to solve it I have seen two suggestions for the first, for my understanding in favor of creation on heritage, it means that both the student and the teacher will have a person's property.
Question two: To do this work, is it true that students and teacher tables will need a foreign key person table? I think I am not fully aware of this solution, and I need some guidance.
In the second solution, students and teachers have to think about the role of a given person plays.
The question (s) I have seen from the person class will require a roll collection, and the link table (personlies?) Is used to record in the student and teacher tables. Three: What is the role base class and individual table? I believe that the student and teacher sub-classes only have their proper qualities. Is it true?
Have any opinions on any solutions? If someone can get a flash-out example on the web, I would love to see it.
Thanks,
Will
Question 1: Not for my knowledge, it is not saying much; I have not used CSLA, but I think this is a NHibernate thing, and it needs to be resolved with NHibernate. Question 2: Yes, ideologically, a person has zero for a student and a teacher, but all students and teachers need a reference to a person. For this, I use Fluent NBibernate, you have to see the equivalent HBM syntax, but:
Public class personmap: Classplap & lt; Person & gt; {Public personmap () {table ("person"); Id (x = & gt; id) .column ("PersonID"); Reference (x => x.Student). Columns of ("Student ID") Nullable (). Cascade.All (); Reference (x = & gt; x.Teacher). The column ("Teacher ID") is tap. Cascade all (); }} Public Class Teacher Map: Classplop & lt; Teacher & gt; {Public TeacherMap () (Table ("Teacher"); Id (X => ID) .Column ("TeacherID"); References (x => x.Person) .Key column ("PersonID"). Cascade.None ();}} Public class studentmap: classmap {public studentmap} (table ("student"); id (x = & gt; id) .Column (" StudentID "); References (x = & gt; x.Person) .column (" PersonID ").No. (). Cascade.None ();}} Now, The person is the highest of this object graph; you can re-educate people, students or teachers But when they save the changes, they always save the person, and the original roles of that person will also survive.
Comments
Post a Comment