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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:06:12+00:00 2026-06-15T20:06:12+00:00

I am trying to apply conditions on foreign key of customer entity i.e Orders,

  • 0

I am trying to apply conditions on foreign key of customer entity i.e Orders, I want to load only the orders whose IsCancelFlag is false.(The result will be of type customer i.e Customer object, and it conatins a set of Order objects) But while iterating through the returned results, I can see all the orders under the customer, irrespective of whether its cancelled or not. Is it possible to apply conditions on foreign key in nhibernate

        ICriteria _criteria= session.CreateCriteria<Customer>();
        _criteria.Add(Expression.Eq("CustomerId", 12));
        _criteria.CreateAlias("FKorders","FKorders");
        _criteria.Add(Expression.Eq("FKorders.IsCancelFlag", false));
        return _criteria.UniqueResult<Customer>();
  • 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-15T20:06:13+00:00Added an answer on June 15, 2026 at 8:06 pm

    your Property names seems weired but maybe you want

    var query =
        from c in session.Query<Customer>()
        from o in c.Orders
        where o.IsCanceled
        select new { Customer = c, Order = o }
    
    var results = query.AsEnumerable()
        .ToLookup(a => a.Customer, a => a.Order);
    

    this will return a ILookup<Customer, Orders>. NHibernate won’t return a Customer with partially initialised Orders since this will be a broken model and change tracking would be broken.

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

Sidebar

Related Questions

I'm trying to perform calculations, apply conditions for the calculated values and count results
i am trying to apply some condition for an Auto generated textfield, the script
Im trying to apply different background color to even and odd items in a
im trying to apply this JSON code to my Google Map: [ { stylers:
I'm trying to apply border-radius effect on a particular div. The code I used
i'm trying to apply the MVVM pattern in my application with MVVM Light. I've
I am trying to apply global application styles to certain control types, however adding
I'm trying to apply contrast and brightness to a bitmap in memory and I'm
I am trying to apply filters to employees to show them just on the
I am trying to apply smoothing filter to image . But I get this

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.