Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 943743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:28:56+00:00 2026-05-15T22:28:56+00:00

One object’s associated with many others: Example: one Post is part of one Blog

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T22:28:56+00:00Added an answer on May 15, 2026 at 10:28 pm

    You can use projection classes. Retrieving only the information you need and not the complete DB record.

    One example:

    HqlBasedQuery query = new HqlBasedQuery(typeof(Post),
            @"
            SELECT tags.Id, tags.Name
            FROM Post post
            INNER JOIN post.Tags tags
            WHERE post.Id = ?
            ORDER BY tags.Name
            ", postId);
            var results = from object[] summary in (ArrayList)ActiveRecordMediator.ExecuteQuery(query)
                          select new YourProjectionClass
                          {
                              Id = (int)summary[0],
                              Name= (string)summary[1],
                          };
            return results.ToList<YourProjectionClass>();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have one object, 'Student', which will be associated with 2 'Course' objects,
In Ruby, can one object destroy another? For example: class Creature def initialize @energy
I've one object User which can have multiple Posts. Example: Load the user with
So I'm writing an application where one object has a bunch of delegate objects
I want to set two properties equal to each other in one object. Here's
Delphi has a standard mechanism where one object can be copied from another, paraphrased
I'm trying to find related objects to one object by matching the objects tags.
I have an app on the market which has just one object instance a1
can I get the list of messages that one object can response in runtime?
Simple situation One object User have many UserGroups. I want to implement on mvc3

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.