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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:27:47+00:00 2026-05-11T08:27:47+00:00

When using Linq2Nibernate is better to make you Repository return a IQueryable? My understanding

  • 0

When using Linq2Nibernate is better to make you Repository return a IQueryable?

My understanding is that if you use Linq to Nibernate the the query will not ‘fire’ until you call .First() or Single() ect ect. So would it not be best to return IQueryable from all you Interfaces so you can build up\manipulate the expression tree before it fires?

My Repositories are called by a services and inherits from IServicie.

EDIT:

First I really appreciate all the answers. But I wan to add a little to the question. I am for this design. I don’t fully understand the reservations around testing. As long as the process is tested at every point IE every filter point then I don’t really see much of a difference.

addition:

Is there any point to Using Linq2Nibernate if your repository doesn’t return IQuerrable?

  • 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. 2026-05-11T08:27:48+00:00Added an answer on May 11, 2026 at 8:27 am

    Personally, I think not. The problem with exposing composable queries from your repository is that you can no longer fully unit test them – their behaviour (and success) is now at the mercy of the caller. For example, they might do .Where(x=>SomeUnmappedMethod(x)) (with no translation). I added more on this here.

    If you have fixed methods that return (for example) IList<T> or T[], then you can be sure that if it works in the unit test, it should work for real (barring any configuration errors). It also means that you can profile the DAL in isolation and have reasonable confidence what SQL (etc) is going to be executed. You can’t profile/optimise a DAL that changes based on the caller.

    (based on my LINQ-to-SQL usage; not LINQ-to-NHibernate specifically)

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

Sidebar

Related Questions

I have a linq query that is passed into NHibernate which Linq2NHibernate will parse
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
Using Browserlab, it appears that the background image is not centred in Firefox7 for
Using PyObjC , you can use Python to write Cocoa applications for OS X.
Using ASP.NET MVC there are situations (such as form submission) that may require a
Using VS2008, C#, .Net 2 and Winforms how can I make a regular Button
Using C#, I need a class called User that has a username, password, active
Using report builder 3.0, I have a report that queries a cube. How do
Using Entity Framework CodeFirst, how do I create a created datetime column that gets
Using restlet, I want to make a post to android's c2dm service. I have

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.