asp.net mvc - Nhibernate (and ORMs in General): work with Objects or ObjectIds? -
It's something that was pulling me for a while.
On one side - OOP / Rich Domain model hand
/ Em> - I think I should pass (context) about the real things about which I am talking about.
On the other side - DB / Web app hands - I think it's easier and more efficient to pass only the integer ID Instead of objects
Consider an ecommerce list type application:
- User is logged in and navigate to a product page
- They post a comment
- With this comment continuing, the planned controller has 3 pieces of information in action: a) User ID (from athlete cookie or from anywhere) , B) Product ID (probably from QuickString), and C) Comment Text.
- Now, what is the best practice here? Does it really increase the user and product objects (for example, they are mixed with all the DB work), when we know that it will be used for everyone, the ORM can read their ID and be appropriate External DB in the table whose keys are stored in the table?
What are people's thoughts on this? Perhaps the web app should be given a little more leverage than other apps, due to their unattractive nature? I think that 'it depends' would be the answer, but perhaps some people are correct about this issue.
This is a common question that may apply to many platforms, but if by giving an example I would probably like ASP.NET MVC .
Thank you.
NHibernate has a properly load operation due to this reason (as opposed to receiving ).
session. Save (new comment {text = commentTextFromScreen, user = session. For example, you are saying NHibernate: I know that they already exist. Load & user> UserID; product = Session. Load (productID)}}
Databases, so do not bother them when they are selected. NHibernate will return proxy objects to them and by the time you return to the object Try not to use any property, until the database Students will not have a choice.
Ayende blog post for more information check out:
Comments
Post a Comment