My application has a User table and a Relationship table (and a class for each) so that it can record friendships between users. The Relationship table has four columns: Id, User1, RelationshipType (a string), and User2. This lets me say that User1 is "friends" with User2, or User1 "blocked" User2, or User1 is "following" User2, or so forth.
In the "old way" (before I started learning Fluent NHibernate), if I wanted to set up a "friend" relationship, I'd make an instance method on my User class so that my controller class could say "user1.AddFriend (user2)". And then the AddFriend method would do something like 'new Relationship(user1, "friend", user2)'. But in the "new way" (Fluent NHibernate) way of doing things, I understand I have to do things differently: 1. The model is nothing but entity mappings; a class modeling one table should not involve any other tables. That sort of thing belongs in the repository classes. 2. For the sake of "dependency injection", I should not have my User class create a Relationship object; I should create this Relationship object separately and then pass it to the User class. But now this has me completely confused, because instead of making a method to allow the controller to do "user1.AddFriend(user2)", the controller instead has to know about the Relationship class, create a new Relationship object, then call a "userRepository.AddFriend(user1, user2)" method I'll write. This seems more complicated. What am I missing here? My apologies for my confusion, but I just don't see the value of the added complexity. Or am I missing a basic concept entirely here? I've heard mention of "Application Services" but I don't know anything about how that plays into this (and I can't find it in the Fluent NHibernate wiki); does the proper approach have something to do with that? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Fluent NHibernate" 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/fluent-nhibernate?hl=en -~----------~----~----~----~------~----~------~--~---
