Hello there,
I've spent a couple of days working on a quite odd idea. Here is my domain:
class Employee { String Id { get; } }
class Friend {
Int32 Id { get; }
Employee Owner { ... }
} //an Employee's friend
those classes belongs to two different hierarchies (/omissis/ for
convenience) mapped with a table-per-subclass strategy. The
application relying on this domain is just a phonebook with a
voicemail box. So there is a VoiceMailMessage entity as well, with a
property 'Sender' representing who has sent the message. The sender
can be an Employee or a Friend. I was thinking to enrich my domain
with an interface:
interface IMessageSender {
Guid SenderIdentifier { get; }
}
and make Employee/Friend implement this interface as well, having:
class Employee : IMessageSender { ... }
class Friend : IMessageSender { ... }
class VoiceMailMessage {
IMessageSender Sender { get; }
}
And here comes the issue: how can I map the 'Sender' property?
Searching some hints in the italian NH users list I have come to the
conclusion that I have to chose between two different approaches:
1. use an <any> mapping. Going down this path, I should have Employee
and Friend class Id of the same type, which I haven't. *But* both
entities implements IMessageSender which have a propety
SenderIdentifier which I could use to implement this mapping. So I'm
asking: is it possible to use a column which is not the table's ID to
implement an <any> mapping? (but I think I can argue the response...)
2. create a view on a union of rows coming from the tables on which
Employee and Friend are mapped, then map a MessageSender class on that
view. In this way I don't know anymore if the object which is a
message sender is an Employee or a Friend.
Any suggestion? Do you know about any other way to do the same stuff?
Thanks in advance!
(and sorry for my english! :-P)
--
regards,
Giulio
--
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.