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?
To expand a bit on @lazyberezovsky, you can use an anonymous type projection to get all of the fields you want:
I don’t know what name and type your product name, description, and price fields are, so you will have to substitute those.