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

  • SEARCH
  • Home
  • 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 7869069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:11:56+00:00 2026-06-03T01:11:56+00:00

I’ve a class with many relations mapped. One of those relations should be fetched

  • 0

I’ve a class with many relations mapped.
One of those relations should be fetched for a concrete user.

public class Company
{
    public int id { get; set; }
    public string Name { get; set; }
    public IList<StocksPack> stocks { get; set; }
    // a lot of other properties referencing other objects
}

public class StocksPack
{
    public int stockId { get; set; }
    public int companyId { get; set; }
    public int amount { get; set; }
    public int ownerId { get; set; }
}

How Do I map the stocks to be left-outer-joined
ON stocks.companyId = company.id AND stocks.ownerId = 123456

Where the actual ownerId is known only at runtime, after the user has logged on to the system.
I want to get all the info about the company and a list of Stocks of that company for the concrete user.

  • 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-06-03T01:11:58+00:00Added an answer on June 3, 2026 at 1:11 am

    I think the premise of your question is mistaken: you don’t map objects on left outer joins. You map them with in a database with a foreign key reference or in nhibernate with a class map like the following:

    public class StockeMap : ClassMap<Stock>
    {
        public EmployeeMap()
        {
            Id(x => x.Id);
            References(x => x.company);
        }
    }
    

    Where stock looked like:

    public class Stock{
         public virtual Company company {get; set;}
    }
    

    And you had some Company object with a map set up that gave it an id field.
    This is the simple parent child id type relationship you have with stock and company. I’m assuming.
    The idea behind hibernate and nhibernate is you don’t have to have the id references in your objects. It handles that for you

    The left outer join only enters in when you query the data. Put another way, the mapping is the relationship between the two types, the query is a statement about how you want that relationship represented and what data you want. The former is a property of your data model and system design, the later some event that happens at runtime.

    There is some ambiguity on what you said you want the query to do, but it appears you want to list all the stocks and, when that stock is owned by a certain owner, the company for that stock as well. The other possibility is that you wanted to list all the companies and , when they have stock owned by a specific id, that stock as well.

    In either case, you want a simple left join query. In fluent bhibernate these look like this:

    from Cat as cat
        left join cat.kittens as kitten
    

    In C# using linq you can use this example:

    var query = from person in people
                        join pet in pets on person equals pet.Owner into gj
                        from subpet in gj.DefaultIfEmpty()
                        select new { person.FirstName, PetName = (subpet == null ? String.Empty : subpet.Name) };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim
I'm making a simple page using Google Maps API 3. My first. One marker
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

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.