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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:40:27+00:00 2026-05-30T15:40:27+00:00

Please forgive me if I am somewhat unclear, I am just getting started with

  • 0

Please forgive me if I am somewhat unclear, I am just getting started with NHibernate/LINQ/Lambda expressions, and I am actually unsure of what to look for…

I’ve been working with .NET 2.0 for the past 4 or 5 years and had no opportunity to evolve other than by myself, which is why I am now getting to learn new tech 🙂

I’ve been reading alot of blogs and posts and started a personal little project where I try to use the Repository pattern as well as possible.

I am now in the following situation:

  • MyProject.Core.dll: I have this core assembly that contains all the business logic and sets the IRepository contract. It knows nothing of the actual implementation of the repository, it is resolved at run time using IoC, so this core dll has no reference to the NHibernate dll’s.
  • MyProject.Data.NHibernate.dll: the implementation of the repository is contained within this assembly that has all the necessary references to the NHibernate dll’s.

My Repository implementation looks something like this:

public class GenericRepository<T> : IGenericRepository<T> where T : class
{
    ...
    public virtual IQueryable<T> All()
    {
        IList<T> entities = Session
            .CreateCriteria( typeof( T ) )
            .List<T>();
        return entities.AsQueryable<T>();
    }
    ...
}

So in my core dll I can get a reference to my repository and do something like:

IList<Person> people = myRepository.All().ToList();

That seems to work well, it queries the database and returns all the rows from the Person table.

However, now what I want to do is add predicates:

IList<Person> daves = myRepository.All().Where(p => p.Name == "Dave").ToList();

This works fine, but of course what happens is that NHibernate first queries the database to return ALL rows, and then LINQ filters the results to only return the ones whose name is “Dave”.

I’ve been looking all over the internet, but I haven’t found how to implement this, also I found many things that seem to be outdated, for example, I often saw calls to the NH session.Linq() method, I looked all over my dll’s, this method is nowhere to be found…

If anyone could point me to the right direction, maybe with a little example or something, I would be very greatful.

Thankd you very much!

  • 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-30T15:40:29+00:00Added an answer on May 30, 2026 at 3:40 pm

    It is quite simple:

    Use session.Query<T>():

    public virtual IQueryable<T> All()
    {
        return Session.Query<T>();
    }
    

    Query<T> is an extension method that lives in the namespace NHibernate.Linq.

    session.Linq is no longer supported. It was the LINQ provider for NHibernate prior to version 3 and has been replaced by Query<T>.

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

Sidebar

Related Questions

Please forgive my simple question. I have just started to use Matplotlib and I
If this has been asked before please forgive me, I could not find it.
Please forgive if this question has been asked numerous times. I recently installed Eclipse
Please forgive me if this question has been answered - I searched and couldn't
Please forgive me if this question has been asked and answered already. If so,
Please forgive me as I am just learning MVC3. I have 2 db tables
Please forgive the noob question. I've been developing this little app (with Unity) for
Please forgive my attempts at necromancy, but I actually need to write some code
Please forgive the poor code and ignorance this is just a late night hack
Please forgive my ignorance. Traditionally I've been doing something like this, but it feels

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.