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 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

Related Questions

I've a requirement where I have to extract metrics from different Java projects (configured
Possible Duplicate: php regex , extract phone number from text/html I have following requirement.
In one of my applications I have the requirement to extract resources from a
I have requirement to disable copy/paste/cut operations on a textbox. For this purpose I
In our project we have requirement that, after receiving sms message from third party
I have a requirement to extract all the text that is present in the
I am trying to extract an image from a HTTP stream. I have a
Here is where I am at this juncture... I have a requirement wherein I
My requirement is to recognize and extract numerical data from a natural language sentence
Requirement: Run svn log -l 1 command and this will have an output like

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.