Here is my situation ..
Suppose you have the following model objects, which are separate tables on their own:
Movies [Movie_Id, Title, Rating, ..]
Actors [Actor_Id, FirstName, LastName, ..]
Director [Director_Id, FirstName, LastName, ..]
And another object / table called the “Recommendations”, which represents the recommendations between users on the website. The idea is that the recommendation can be of any type, that is, someone recommending an actor, or someone recommending a film. Basically, the table should look something like this:
Recommendations [Recommendation_Id, Object_Id, Object_Type, ..]
And this is what I'm stuck with. How to match these relationships in nHibernate with Fluent? I mean, when matching, I cannot specify the type (associated with the table) because it is determined at run time, but I cannot rely solely on Id because it itself cannot imply which table it belongs to.
For example, imagine this entry in the recommendation table:
Recommendation_Id - Object_ID - Object_type
83001-4010123 --- "M"
I basically store the char identifier (in this case, “M” stands for the “Movies” table) to find out which table Object_Id belongs to. I cannot just save Object_Id without Object_Type ..
As a final comment, I would like to add that I saw all the tables per class, tables per subclass, tables for a specific class of examples, but I believe that none of them are suitable in this situation, since Movies_Id, Actors_Id, Directors_Id , ... are all different between them, so Recommended_Id. I mean that there is no inheritance of the base class and child class, they do not use Id at all.
I hope I clarify. Thanks in advance.
mapping nhibernate fluent-nhibernate
Matias bello
source share