Hello dear NHibernate users!
I have the following model:
class Post {
int Id;
ICollection<string> Tags;
}
class SomeotherClass {
int Id;
ICollection<string> Tags;
}
How can I map these two entities to the same table? (The Tags property.)
I know how you can map them with many-to-many, but I want to keep just
one unique tag in the database. How can I do that and instruct
NHibernate to do some sort of check and just get the Id if it already
exists?
post = new Post {
Tags = {
"NHibernate",
"Rocks"
}
}
someOtherClass = new SomeOtherClass {
Tags = {
"NHibernate",
"Rocks"
}
}
session.Save(post);
session.Save(someOtherClass);
Will only result in two insertions to the Tags table.
How can I do this?
// Kim Johansson
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---