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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:18:39+00:00 2026-05-25T20:18:39+00:00

Looking through some of our business logic code I’ve found where some methods are

  • 0

Looking through some of our business logic code I’ve found where some methods are being passed an un-executed IEnumerables as a parameters such as this:

GetDetails(IEnumerable <Entity> item) { // do something with the item }

Now the code works fine as is, but what I’m seeing when I’m in debug is that the parameter is passing a raw query, not a collection of anything. To me this seems a little wrong since you could be hitting the database every time that this IEnumberable is used if the query is pointed at a database.

So what i’m asking, is passing an un-executed IEnumerable as a parameter to a method bad practice?

After more investigation

I’ve read around more on stackoverflow, and found this particular question where Eric Lippert says:

Remember, a query expression gives you an object which represents the query itself. The object does not represent the RESULTS of the query, the object represents a query. Think of it as a SQL query string, only smarter. You ask the query for its results, and the query executes. You ask it again, the query executes again; no guarantees that the results are the same the second time you ask; the world might have changed since then

To me, this seems to say that if you’re going ot use a defered query such as an IEnumberable, to be careful where you use it, and when you use as you might not get the results which are expected. But further into the answers I see that Bevan says he personally does this:

Parameters to methods – use IEnumerable unless there’s a need for a more specific interface.

So my question still stands, is passing an un-executed IEnumerable as a parameter to a method bad practice or should I not care about the when the data is requested, just that it is requested.

  • 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-25T20:18:40+00:00Added an answer on May 25, 2026 at 8:18 pm

    Once the data leaves the business logic layer, it should IMHO be a hard collection that is no longer connected to the database. Passing a collection between methods in the Business Logic should be ok because you may want to add criteria/filtering to your query without loading the entire data set from the database.

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

Sidebar

Related Questions

Looking through some code I came across the following code trTuDocPackTypdBd.update(TrTuDocPackTypeDto.class.cast(packDto)); and I'd like
I'm looking through some code for learning purposes. I'm working through this portion of
So I'm looking through some code, and I see this: class whatever { public:
I have been looking through some code on an open source project recently and
I'm running some code through FxCop and am currently looking at clearing all of
Looking through our MMC snap-in code I can't get one concept. We have a
I was just looking through some information about Google's protocol buffers data interchange format.
I've done some looking through the site and on the Internet trying to find
We are looking to run a large amount of data through some unit tests.
In one of my current side projects, I am scanning through some text looking

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.