I think the answer would depend on UI. Are you showing all book
reports or are you picking a student or teacher first to narrow down book
reports?
Sergey Barskiy
Principal Consultant
office: 678.405.0687 |
mobile: 404.388.1899
Magenic ®
Microsoft Worldwide Partner of the Year | Custom
Development Solutions, Technical Innovation
From: dhtroy
[mailto:cslanet@lhotka.net]
Sent: Friday, August 22, 2008 9:38 AM
To: Sergey Barskiy
Subject: [CSLA .NET] What to do when the table is both a Parent and
Child
I'm new to CSLA, and have been thrown into rather quickly;
I've tried searching for this answer already but haven't been able to locate it
(most likely because I'm not entirely certain how to word what I'm searching
for)
I have table that is both a parent to another table (one-to-many relationship)
and has a (many-to-one) relationship with two other tables; in my attached
diagram, this table would be the "book reports" table (real table
names changed to protect the innocent).
We use NHibernate to map from the Database to DTOs, and then CSLA for our
Business objects. My problem is how to properly set-up my business object so
that I can get/set instances of the "Student" and "Teacher"
objects through the "Book Reports" business object. (I hope that
makes sense).
Can someone please point me in the right direction?
Thank you.
Ok, then here is my take on design:
1.
BookReports (BLB)
a. Book
Report (BB)
i.
Teacher (one, not list since it is 1-n relationship, probably ROB
if you cannot modify it, which is my assumption)
ii. Student
(one, not list since it is 1-n relationship, probably ROB if you cannot modify
it, which is my assumption)
I would load appropriate teacher and student during fetch of
each Book Report.
Sergey Barskiy
Principal Consultant
office: 678.405.0687 |
mobile: 404.388.1899
Magenic ®
Microsoft Worldwide Partner of the Year | Custom
Development Solutions, Technical Innovation
From: dhtroy
[mailto:cslanet@lhotka.net]
Sent: Friday, August 22, 2008 9:53 AM
To: Sergey Barskiy
Subject: Re: [CSLA .NET] RE: What to do when the table is both a Parent
and Child
Thanks for the quick response:
We're showing all book reports in a list.
Apologies for dredging up such an old thread, but, out of curiosity, would you suggest that the Teacher property in BookReport should be an instance of a TeacherInfo object or just its ID? I've gone with the former out of habit, but the latter option binds more nicely to TeacherList (in the same way as with NameValueLists) and lightens the BookReport object a bit. Of course, this comes with the downside of having to call TeacherInfo.GetTeacherInfo(<BookReport instance>.Teacher) anytime you want to use the TeacherInfo object in any way.
Copyright (c) Marimer LLC