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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:57:35+00:00 2026-05-16T00:57:35+00:00

Possible Duplicate: Learning about LINQ Hi everyone, I just want to understand what exactly

  • 0

Possible Duplicate:
Learning about LINQ

Hi everyone,

I just want to understand what exactly is LINQ in DOTNET? And How does it work?

Tx

  • 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-16T00:57:36+00:00Added an answer on May 16, 2026 at 12:57 am

    LINQ is many things, it’s the combination of many smaller things.

    This answer is going to be a jumble of information, I apologize. Your best bet is to wait a bit and see if someone else summarizes it better, and do google for the keywords I use.

    LINQ stands for “Language INtegrated Query”, and the most naive interpretation is that they added SQL-like syntax to the C# programming language.

    So instead of:

    IEnumerable<int> values = otherValues.Where(i => i > 5);
    

    they have the syntax:

    IEnumerable<int> values = from i in otherValues
                              where i > 5
                              select i;
    

    The C# compiler will actually translate the second piece of code above to the first piece of code, so in reality, you’re just calling methods on the collections.

    However, and here’s another part of the puzzle. Those methods are not actually defined in the collections at all. They’re defined as extension methods, which means they’re defined somewhere else, with some trickery that basically says “let the programmer use these methods as though they were defined in the collection type to begin with, and just fix the code during compilation”.

    So the first piece of code above:

    IEnumerable<int> values = otherValues.Where(i => i > 5);
    

    actually ends up being compiled as:

    IEnumerable<int> values = Enumerable.Where(otherValues, i => i > 5);
    

    The Where method is defined here: Enumerable.Where.

    Next piece of magic is that the C# compiler doesn’t use Enumerable.Where, what it does is that it just rewrites the code on the fly to look like the second piece of code in my answer here, and let the normal type inference work it out. In other words, it’s going to pretend you actually wrote the second piece of code, and then see that “otherValues” is a List<T> where T is an int, and then find that Enumerable.Where is the one to call.

    This means that you can, for other types than collections, actually make your own implementations of Where, and the LINQ syntax would be none the wiser.

    This means … that things that aren’t really in-memory collections can be queried. For instance, if “otherValues” above is something that knows how to get data from a database, a different Where method will be called, not the one in Enumerable.Where.

    This allows those other implementations to do their things in their own way, for instance by writing the SQL for you, executing it, and packaging up the result so that it looks to the calling code as though it actually was an in-memory collection to begin with.

    Next piece of magic is expressions. The parameter to the Where method above, i => i > 5 is a lambda expression, or an anonymous method, in most cases, and you could actually declare it like this for an in-memory collection:

    Func<int, bool> w = delegate(int i) { return i > 5; };
    IEnumerable<int> values = otherValues.Where(w);
    

    However, expression support in C# means that you can also declare it as:

    Expression<Func<int, bool>> w = i => i > 5;
    

    Here, the compiler isn’t actually storing it as a compiled piece of code, but rather an in-memory data structure that knows that it takes one argument, compares it to 5 with a greater-than comparison and returns the result. Note that you have to use the lambda way of writing it, not as a delegate.

    This knowledge allows those other Where implementations, if they’re declared to take expressions, to not only get a hold of the “where clause”, but to look at it, pick it apart, and rewrite it.

    Which means that generating that SQL can be done in the Where method that knows how to deal with SQL code.

    Here’s the LINQ to SQL declaration of the Where method: Queryably.Where.

    So LINQ is the combination of many smaller pieces of technology added to the C# compiler:

    • LINQ syntax
    • Extension methods
    • LINQ extension methods (+ other implementations, in particular look at LINQ to SQL.)
    • Lambda expressions and Expression trees.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How can I understand nested ?: operators in PHP? Why does this:
Possible Duplicate: check whether internet connection is available with C# I just want to
Possible Duplicate: Setting variable to NULL after free … I am learning about good
Possible Duplicate: PHP: Notice: Undefined variable and Notice: Undefined index I am just learning
Possible Duplicate: What does # mean in LISP I am learning lisp, but one
Possible Duplicate: MVVM: Tutorial from start to finish? i just started learning WPF. i
Possible Duplicate: C# GUI Programming Starting… I want my brother learn about Microsoft .Net
Possible Duplicate: What does !! mean in ruby? I'm learning ruby/rails and found a
Possible Duplicate: count duplicate elements in ruby array I just started learning ruby and
Possible Duplicate: servlet vs filter I am java beginner. Now I am learning about

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.