One object's associated with many others:
Example: one Post
is part of one Blog
, has a list of relations with Tags
, and many other things.....
Then I've one web form with dropdown boxes, each one filled from a custom query to retrieve only the Id and Name of that object, I am not getting ALL the object because it can have big size values (don't ask me why, but it can happen) and also because I don't need the other attributes to build the drop down box.
Now when I try to create this new Post
I need to do something like this:
Post post = new Post();
post.Blog = blog;
.....
Before ORM I could use SQL queries to create the object and pass only the Id of the blog, but now I need to pass the blog object. This means I'll need to retrieve it from the DB just to create the post, and this post also need tags objects and other things. I think this is an unnecessary operation. Why do I need to get all the other objects to create something else ?
There is a similar question here but without accepted answer.
I also will not cache the objects from the drop down boxes for the reasons I explained before.
I would like to create this post
passing only the Id
of the blog
. Is there any way to do this?
.
Note: using NHibernate but I think this is general ORM question.