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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:48:52+00:00 2026-06-05T20:48:52+00:00

I want to add LINQ support to my library, so I can use SQL

  • 0

I want to add LINQ support to my library, so I can use SQL like queries on it like you can with System.Xml. How do I do that?

  • 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-05T20:48:53+00:00Added an answer on June 5, 2026 at 8:48 pm

    Implementing LINQ simply means implementing the methods LINQ expects to be there, such as Where or Select, with the correct signatures. Despite common perception, you do not have to implement the IEnumerable interface for your class to support LINQ. However, implementing IEnumerable will automatically get you the entire set of LINQ methods on the Enumerable class almost for free — you only have to implement GetEnumerator and an IEnumerator class.

    There are a couple of examples on how to implement IEnumerable on my blog, in this post about the Iterator pattern.

    However, if it doesn’t make sense for your class to be enumerable, you don’t need to do so. You just need to implement the appropriate LINQ methods directly. LINQ doesn’t actually care how the methods get defined, so long as the C# compiles. That is, if you write:

    from p in myPlist where p.Thing == "Thing" select p;
    

    the C# compiler translates this into:

    mpPlist.Where(p => p.Thing == "Thing").Select(p => p);
    

    As long as that compiles, LINQ will work. To see the correct signatures for the methods, look as the MSDN documentation’s list of LINQ query methods. For example (assume that your PList was a list of PListItems):

    public class PList
    {
      public IEnumerable<PListItem> Where(Func<PListItem, bool> predicate)
      {
        foreach (var item in this.items)
        {
          if (predicate(item)) 
          {
            yield return item;
          }
        }
      }
    }
    

    While implementing LINQ directly in this manner gives you a lot more control over how it behaves, it’s a lot more work to get it right, and you need to understand the implications of your return values, and chaining LINQ calls, etc. In general, if you can get away with making your class implement IEnumerable and let C# do all the work for you, things go much easier.

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

Sidebar

Related Questions

I have a linq statement that I want to add an additional where clause
I want to add some rows to a database using Linq to SQL, but
I have a list of string values that I want add to a hashtable
I have two long type columns that I want to concat during sql query.
I Want to add the data to the xml file from my asp.net GUI.So
I would like to extend a class generated by Linq To Sql to initialize
Suppose I have linq expression q, then I want to add a sort to
Using Linq to Entities, I have an IQueryable<T> and want to add another WHERE
Hi i want to add the result of sql query to datagrid in my
I have this LINQ query and want to add a second orderby. var clients

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.