Hi,
We just created a new domain for contact details. Basically we make a
separation between Person and Company, and have a base class called
ContactDetail. The ContactDetail class looks as follows:
public abstract class ContactDetail : DomainAggregate
{
public int ClientNo { get; set; }
public abstract string Name { get; set; }
public Address Address { get; set; }
public Address PostAddress { get; set; }
}
The other classes (Person and Company) inherit from this class and
override Name. (Person has more detail and the name will be formatted
as "Mr. D. Perfors" using properties in the Person class)
The DomainAggregate class has an ID (a Guid) and the ClientNo is there
for legacy purposes.
The problem is that we have to map against a legacy database.
Basically this is quite simple, this is how the tables look like:
Person:
ClientNo (int)
Name
Title
MV
Forenames
Street
Number
PostalCode
Place
Company:
ClientNo (int)
Name
Street
Number
PostalCode
Place
Post_Street
Post_Number
Post_PostalCode
Post_Place
I have two mappings, one for Person and one for Company. This works
pretty well, but now comes the problem...
The ClientNo in both tables are unique, so a ClientNo in the Person
table doesn't exist in the Company table and vice versa.
In our software we want to search on ClientNo and want to get
ContactDetail from NHibernate, and we don't care whether it is a
Company or a Person. This doesn't work in this situation. So I tried
to map it using a union-subclass and make a mapping for ContactDetail
as well, but then I get the problem that it doesn't run the queries
because it can't "DISTINCT".
What is the best mapping solution for this kind of problems? Or did I
missed something in the documentation?
Greetings,
David
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---