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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:10:03+00:00 2026-06-12T09:10:03+00:00

I am getting started with LINQ and NHibernate, can you help me get oriented

  • 0

I am getting started with LINQ and NHibernate, can you help me get oriented please:

I need to pass a lambda statement to nhibernate .QueryOver() which is conditional based on a property on my model:

if (model.PropertyA != String.Empty) {
    var searchResults = nhibSession.QueryOver<type>(x => 
                                             x.propA == model.PropertyA)
                                   .List();
}

Is there a better way to do this using a C# Expression instead of a lambda statement? How do I create an Expression using model.PropertyA? Do I use Expression.Property() or Expression.Field()?

thanks

  • 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-12T09:10:04+00:00Added an answer on June 12, 2026 at 9:10 am

    How do I create an Expression using model.PropertyA?

    I suspect you should be using Expression.Constant – even though it doesn’t “feel” like a constant in the normal sense, it’s constant for that expression as the model isn’t part of the input to the expression.

    Expression foo = Expression.Constant(model.PropertyA);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Getting started with NHibernate How can I generate identity fields in nHibernate using Hilo
I'm just getting started with Linq-to-SQL and data binding in WPF, most of which
Just getting started with MSpec and I can't seem to quite get my first
I am getting a little confused and need some help please. Take these two
I'm just getting started with LINQ, and I'm having some troubles. Say I wanted
I have Silverlight Application. Getting started with Linq I find out I have to
So I've just started working with linq as well as using lambda expressions. I've
Just getting started here and cannot seem to get this very basic thing working.
Hi I'm just getting started on the v4 CTP so I can see me
Please forgive me if I am somewhat unclear, I am just getting started with

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.