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 6801863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:09:09+00:00 2026-05-26T19:09:09+00:00

I got a follow up question to this question. I use Silverlight and WCF,

  • 0

I got a follow up question to this question.

I use Silverlight and WCF, where lazyloading isn’t an option. How can i ignore a HasMany relation programmatically in some cases improve performance? (I just want the Foo’s without the related Bars).

  • 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-26T19:09:10+00:00Added an answer on May 26, 2026 at 7:09 pm

    Basically, what you’re trying to do is not possible, be it NHibernate or Fluent. You can’t have mapping saying “sometimes load, sometimes not”. Setting Not.LazyLoad() is pretty much show stopper – NHibernate will load collection always, entirely.

    Those kind of optimization (sometimes load, sometimes not) are better suited to be handled at DAO part of your model. For example, you could have your FooDao class looking like this:

    public class FooDao
    {
        public IList<Foo> GetFoosEagerly()
        {
            // load all Foos first; then all Bars for every Foos
            var foos = session.QueryOver<Foo>().List();
            foreach (var foo in foos)
            {
                NHibernateUtil.Initialize(foo.Bars);
            }
    
            return foos;
        }
    
        public IList<Foo> GetFooPerformanceCritical()
        {
            return session.QueryOver<Foo>().List();
        }
    }
    

    With standard mapping (as in, not using Not.LazyLoad()), first method will still return Foos with Bars collection fully set (we just need to tell NHibernate to load them now, before we return). However, second one tho will return Foo objects only. No single Bar will be loaded. Instead, NHibernate will generate proxy object in place of Bars collection for every Foo.

    Your WCF service can use such DAO object internally. Naturally, you can have similar methods to load single Foo.

    Conclusion is simple; mappings alone won’t help you with your problem. You need to do some extra coding work, but it definitely is possible.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Follow up to this question about GNU make : I've got a directory, flac
You can consider this a follow-up question to How do I install the OpenSSL
This question is a follow-up to one I asked and got answered here: How
this is a follow up question from my previous one. you can find it
i recently asked this question and i got a lot of great answers breaking
So this is essentially a follow-up question on Finding duplicate records . We perform
Not sure if this question belongs on stackoverflow.... I'm trying to follow along with
This might be a duplicate question, however I did search and I got so
The question How can I monkey-patch an instance method in Perl? got me thinking.
When I asked this question I got almost always a definite yes you should

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.