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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:05:02+00:00 2026-05-17T20:05:02+00:00

I am getting an IQueryable from my database and then I am getting another

  • 0

I am getting an IQueryable from my database and then I am getting another IQueryable from that first one -that is, I am filtering the first one.
My question is -does this affect performance? How many times will the code call the database? Thank you.

Code:

DataContext _dc = new DataContext();

IQueryable offers =
(from o in _dc.Offers
select o);

IQueryable filtered =
(from o in offers
select new { ... } );

return View(filtered);
  • 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-17T20:05:02+00:00Added an answer on May 17, 2026 at 8:05 pm

    The code you have given will never call the database since you’re never using the results of the query in any code.

    IQueryable collections aren’t filled until you iterate through them…and you’re not iterating through anything in that code sample (ah, the beauty of lazy initialization).

    That also means that each of those statements will be executed as its own query against the database which results in no performance cost over doing two completely independent queries.

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

Sidebar

Related Questions

Getting red warning message that expected identifier for this statement CALayer = ImageView.layer; Using
Let say I have a method (example taken from another post): public IQueryable<CityBlock> GetCityBlocks(){
Have problem while getting data from Memcached on .NET MVC solution. I have this
I'm getting stackoverflow exceptions on the following code... IQueryable<MilestoneList> ml = from MilestoneList d
I have a domain service, derived from LinqToEntitiesDomainService<FOOEntities> It has one method, IQueryable<Bar> GetBar().
Getting this out of the way; I don't frequently do much in php or
Getting this weird LINQ error. title = System.Linq.Enumerable+WhereSelectEnumerableIterator`2[System.Xml.Linq.XElement,System.String Here is the code I have:
Getting a strange error when trying to insert data into an Access database using
This is the scenario: 2 Entities: tree and another tree id idParent someValue 1
I'm trying to build a Silverlight App that accesses and presents data from a

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.