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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:12:33+00:00 2026-05-10T19:12:33+00:00

Ok, the more I use LINQ, the more I like it! I recently found

  • 0

Ok, the more I use LINQ, the more I like it! I recently found myself working in some legacy code at work. It is your classic DataSet and DataTable rich application. Well, when adding a bit of functionality I found myself really wanting to just query the rows of a DataTable for the results I was looking for.

Let me repeat that… instead of looping and adding to a temp collection, I just wanted to ask the Rows collection for what I needed. No looping, no temp variables, just give me what I want.

var customerOrderIds = table.Rows.Cast<DataRow>()    .Where(x => (string)x['CUSTOMER_ID'] == customerId)    .Select(x => (string)x['CUSTOMER_ORDER_ID'])    .Distinct(); 

My question is whether or not this is a good thing, or am getting carried away with LINQ? It does seem to me that this declarative style of pulling a subset of data out of a collection is a good thing and more readable in the end. But then again, maybe I’m just smitten 🙂

  • 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. 2026-05-10T19:12:34+00:00Added an answer on May 10, 2026 at 7:12 pm

    One other observation; if you aren’t using typed datasets, you might also want to know about the Field<> extension method:

        var customerOrderIds = table.Rows.Cast<DataRow>()        .Where(x => x.Field<string>('CUSTOMER_ID') == customerId)        .Select(x => x.Field<string>('CUSTOMER_ORDER_ID'))        .Distinct(); 

    Or using the query syntax:

       var customerOrderIds = (         from row in table.Rows.Cast<DataRow>()         where row.Field<string>('CUSTOMER_ID') == customerId         select row.Field<string>('CUSTOMER_ORDER_ID')      ).Distinct(); 

    I’m not saying it is better or worse – just another viable option.

    (Actually, I don’t use DataTable very much, so YMMV)

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

Sidebar

Related Questions

The more I use Parallel.ForEach and PLINQ in my code, the more faces and
I would like to have a nice clean LINQ code that can get an
I use LINQ on a Dictionary<string, IList<ID>> like this: var searchCategories = new List
Can any body tell me how can I use a LIKE operator using System.Linq.Dynamic
I would like to use Linq to query a bus schedule in my project,
I want to use Linq expression for some dynamic features. I need And, Or
The more and more I use the LINQ the more and more I really
I'm looking to understand a bit more about LINQ and use it a little
is there a way to configure trac to use more than one svn repo
I am interested in an array of software ideas and use more than one

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.