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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:23:33+00:00 2026-05-26T18:23:33+00:00

I’m comparing Entity Framework with NHibernate, and I’d like to know if when using

  • 0

I’m comparing Entity Framework with NHibernate, and I’d like to know if when using SQL Server, what effect (if any) would enabling or disabling MARS support have on NHibernate?

MARS = Multiple Active Result Sets

The Entity Framwork documentation states the following:

When you call the Load method during a foreach (C#) or For Each
(Visual Basic) enumeration, the Entity Framework tries to open a new
data reader. This operation will fail unless you have enabled multiple
active results sets by specifying multipleactiveresultsets=true in the
connection string. For more information, see Using Multiple Active
Result Sets (MARS)
on MSDN. You can also load the result of the query
into a List collection, which closes the data reader and enables you
to enumerate over the collection to load referenced entities.

Does NHibernate has the same issue?

Additional information when connecting to SQL Azure

  • 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-26T18:23:33+00:00Added an answer on May 26, 2026 at 6:23 pm

    The issue you’re referring to is linked to “server side cursors”, and as far as I know of nHibernate this shouldn’t be an issue, simply because it don’t use them.
    If you’re using LINQ to load objects in nHibernate, on the first access to the foreach enumeration, nHibernate load in memory the whole resultset of the query, and this way it can use the session’s connection to load everything else.
    When using HQL query or Criteria, it will load the resultset when you call “List()” then it close the connection.

    Entity framework on the flip side, try to be smart and make use of server side cursors when scrolling a collection via a foreach enumeration, so the objectContext’s connection is “busy” with the server side cursor until the foreach enumeration is ended. If MARS is not enabled, EF can’t use the connection to load another resultset (you can still issue other statements such update, insert and delete) and thus it will give you an error like “There is already an open DataReader associated with this Command which must be closed first” or something similar.

    Hope this helps,

    Marco

    EDIT:

    After some research I’ve found that nHibernate could use MARS, but still in ver 3.2.0.4000 there’s no driver for SqlServer that supports it. Of course in the SqlClientDriver is not supported (as it is inteded for Sql2000 that has no support for MARS) but even in the Sql2008ClientDriver the relevant property is set to false. Anyway this is something I’ll post to the nHibernate team as soon as possible

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

Sidebar

Related Questions

I would like to count the length of a string with PHP. The string
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

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.