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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:52:20+00:00 2026-06-03T22:52:20+00:00

I have to select specific column from my DataTable using linq I am using

  • 0

I have to select specific column from my DataTable using linq
I am using this code

ds.Table[0].AsEnumerable().Where<DataRow>(r=>r.Field<int>("productID")==23).CopyToDataTable();

~

But it is giving me all columns and I need only PRODUCTNAME , DESCRIPTION , PRICE

How I can write this query?

  • 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-03T22:52:22+00:00Added an answer on June 3, 2026 at 10:52 pm

    To expand a bit on @lazyberezovsky, you can use an anonymous type projection to get all of the fields you want:

    ds.Table[0].AsEnumerable()
        .Where<DataRow>(r => r.Field<int>("productID") == 23)
        .Select(r => new { ProductName = r.Field<string>("productName"), 
                           Description = r.Field<string>("description"),
                           Price = r.Field<decimal>("price") });
    

    I don’t know what name and type your product name, description, and price fields are, so you will have to substitute those.

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

Sidebar

Related Questions

I have a <select>. Using JavaScript, I need to get a specific <option> from
I have written a code that searches specific string from database table.what i want
Let's say I have SELECT name FROM table which gives me something like foo
suppose I have SELECT * FROM table t GROUP BY j HAVING condition_one OR
I have a table. In this table have select element. How can I find
so suppose I have this query SELECT COUNT(*) FROM (SELECT * FROM k JOIN
I have a query that picks out a specific row/column from a large database.
I have one de normalized table. I want to select all the values from
Let's say I have table with column 'URL' whrere I store urls like this
How to get specific column from model in Django( SELECT city FROM advert )

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.