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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:29:27+00:00 2026-06-01T10:29:27+00:00

In LINQ Where is a streaming operator. Where-as OrderByDescending is a non-streaming operator. AFAIK,

  • 0

In LINQ Where is a streaming operator. Where-as OrderByDescending is a non-streaming operator. AFAIK, a streaming operator only gathers the next item that is necessary. A non-streaming operator evaluates the entire data stream at once.

I fail to see the relevance of defining a Streaming Operator. To me, it is redundant with Deferred Execution. Take the example where I have written a custom extension and consumed it using the where operator and and orderby.

public static class ExtensionStuff
{
    public static IEnumerable<int> Where(this IEnumerable<int> sequence, Func<int, bool> predicate)
    {
        foreach (int i in sequence)
        {
            if (predicate(i))
            {
                yield return i;
            }
        }
    }
}

    public static void Main()
    {
        TestLinq3();
    }

    private static void TestLinq3()
    {
        int[] items = { 1, 2, 3,4 };

        var selected = items.Where(i => i < 3)
                            .OrderByDescending(i => i);

        Write(selected);
    }



    private static void Write(IEnumerable<int> selected)
    {
        foreach(var i in selected)
            Console.WriteLine(i);
    }

In either case, Where needs to evaluate each element in order to determine which elements meet the condition. The fact that it yields seems to only become relevant because the operator gains deferred execution.

So, what is the importance of Streaming Operators?

  • 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-06-01T10:29:29+00:00Added an answer on June 1, 2026 at 10:29 am

    There are two aspects: speed and memory.

    The speed aspect becomes more apparent when you use a method like .Take() to only consume a portion of the original result set.

    // Consumes ten elements, yields 5 results.
    Enumerable.Range(1, 1000000).Where(i => i % 2 == 0)
        .Take(5)
        .ToList();
    
    // Consumes one million elements, yields 5 results.
    Enumerable.Range(1, 1000000).Where(i => i % 2 == 0)
        .OrderByDescending(i => i)
        .Take(5)
        .ToList();
    

    Because the first example uses only streaming operators before the call to Take, you only end up yielding values 1 through 10 before Take stops evaluating. Furthermore, only one value is loaded into memory at a time, so you have a very small memory footprint.

    In the second example, OrderByDescending is not streaming, so the moment Take pulls the first item, the entire result that’s passed through the Where filter has to be placed in memory for sorting. This could take a long time and produce a big memory footprint.

    Even if you weren’t using Take, the memory issue can be important. For example:

    // Puts half a million elements in memory, sorts, then outputs them.
    var numbers = Enumerable.Range(1, 1000000).Where(i => i % 2 == 0)
        .OrderByDescending(i => i);
    foreach(var number in numbers) Console.WriteLine(number);
    
    // Puts one element in memory at a time.
    var numbers = Enumerable.Range(1, 1000000).Where(i => i % 2 == 0);
    foreach(var number in numbers) Console.WriteLine(number);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

LINQ: Is it more efficient to use the Single() operator over First() when ever
Linq has this handy function Where that lets me filter the results of an
linq only supports inner join, how to do left join using linq query. also
LINQ operators operate on the assumption that input sequences are not sorted, which is
My Linq statement gives an error. Now the issue is that I'm at a
Linq has a convenient operator method called Take() to return a given number of
LINQ uses a Deferred Execution model which means that resulting sequence is not returned
LINQ uses a Deferred Execution model which means that resulting sequence is not returned
In LINQ, I write a query for data, which is between two dates. In
I have a data table that contains a one-to-many self referential relationship: Plant {

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.