Link to home
Start Free TrialLog in
Avatar of AWestEng
AWestEngFlag for Sweden

asked on

Get Data from Datatable using LINQ

Hi

I need some data from a DataTable, I like to get this using LINQ

Somthing like this
[check code snippet]

But with this code I get the error message:
Could not find an implementation of the query pattern for source type 'System.Data.DataTable'.  'Where' not found.
Var someData= from o in myDataTable where o.TestColumn1 == "SomeText" select o.TestColumn2;

Open in new window

Avatar of greatsubash
greatsubash
Flag of India image

Avatar of AWestEng

ASKER

Found this..

var query = from r in employeeDataTable.AsEnumerable()
            where r.Field<string>("LastName") == "Raman"
            select r.Field<string>(“FirstName”);  
Avatar of Fernando Soto
Hi AWestEng;

Your last post should give you what you need. Is that working?

Fernando
any tips how to get the data from query ? convert it to a string?
I can see that the data is in the var, but I can't get it out.
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial