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

  • Home
  • SEARCH
  • 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 77007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:45:45+00:00 2026-05-10T20:45:45+00:00

I have a requirement to extract a distinct subset of rows from a DataTable,

  • 0

I have a requirement to extract a distinct subset of rows from a DataTable, and thought LINQ2DataSets may be a useful and clean way to do this, however it appears that it is not possible to simply identify return rows from a LINQ2DS query as follows

var result = from r in fips.AsEnumerable() select r.Field<string>('FACILITY_PROCESS_SUB_GROUP_CODE'), r.Field<string>('PROCESS_SUB_GROUP_NAME'), r.Field<string>('... 

as I start getting errors after the first comma.

Is this a correct assumption, and how would I get around it to return a subset of columns from the dataset that I can apply a Distinct() method to?

  • 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-10T20:45:46+00:00Added an answer on May 10, 2026 at 8:45 pm

    You forgot the new statement and field names:

    var result = from r      in fips.AsEnumerable()      select new     {         FacProcess = r.Field<string>('FACILITY_PROCESS_SUB_GROUP_CODE'),         GroupName = r.Field<string>('PROCESS_SUB_GROUP_NAME'),         Item3 = r.Field<string>('Item3')     }; 

    You can also explicitly declare that you are going to use a type:

    var result = from r      in fips.AsEnumerable()      select new MyType('InitClassParams')      {         FacProcess = r.Field<string>('FACILITY_PROCESS_SUB_GROUP_CODE'),         GroupName = r.Field<string>('PROCESS_SUB_GROUP_NAME'),         Item3 = r.Field<string>('Item3')     }; 

    Scott Guthrie (VP Developer Devision, Microsoft) has some good info about LINQ (he talks about LINQ to SQL, but most of it applies regardless).

    Then apply the distinct clause:

    var result = from r      in fips.AsEnumerable()      select new     {         FacProcess = r.Field<string>('FACILITY_PROCESS_SUB_GROUP_CODE'),         GroupName = r.Field<string>('PROCESS_SUB_GROUP_NAME'),         Item3 = r.Field<string>('Item3')     }     distinct; 

    Then put it to a list or iterate over it. Nothing will be selected/distincted/etc until something like on of the following is run:

    var list = result.ToList() foreach(var item in result) {} 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 253k
  • Answers 253k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer HttpContext.Current is not available inside of Session_End, but you can… May 13, 2026 at 9:56 am
  • Editorial Team
    Editorial Team added an answer I fear spending the least amount of time together with… May 13, 2026 at 9:56 am
  • Editorial Team
    Editorial Team added an answer http://msdn.microsoft.com/en-us/library/bb383977.aspx namespace ExtensionMethods { public static class MyExtensions { public… May 13, 2026 at 9:56 am

Related Questions

I have a legacy Java webservice based on Axis2. This webservice classes consist of:
I will soon be beginning work on a project that (from the spec) reminds
Very simple problem. I have a Delphi application and I want to restrict access
to all. i developing a webpage using asp.net with c# language, in this webpage

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.