This is a migrated thread and some comments may be shown as answers.

Datatable does not contain a definition for AsEnumerable LinqBridge

2 Answers 884 Views
LINQ (LINQ specific questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
A.
Top achievements
Rank 1
A. asked on 06 Oct 2010, 02:57 PM
Hi, i'm trying to use linq in c#2.0(linqbridge) to search for a patient name in my database, but i'm getting the following errors: System.Data.Datatable does not contain a definition for AsEnumerable() System.Data.Datatable does not contain a definition for CopyToDataTable()

I added the linqBridge.dll reference to my project. And i'm using:

using System.Linq;

            List<string> names = name.Split(' ').ToList();
            SqlConnection con = new SqlConnection(m_connection_string);
            SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM PATIENT", con);
            DataSet ds = new DataSet();
            da.Fill(ds);

            var query =
            from pat in ds.Tables["PATIENT"].AsEnumerable().Where(c => names.All(val => c.PAT_SEARCH_NAME.Contains(val)))
            select pat;

            DataTable table = query.CopyToDataTable();

What am i doing wrong? I already read that this version of LinqBridge(1.1) does not contain this methods.. Is there a way to solve this?

Thanks.

2 Answers, 1 is accepted

Sort by
0
Damyan Bogoev
Telerik team
answered on 11 Oct 2010, 08:26 AM
Hello A.,

I prepared a sample application which demonstrates how to achieve this goal. I implemented extension methods for the missing functionality because the project targets .NET Framework 2.0. Both of the AsEnumerable and CopyToDataTable methods are supported in .NET Framework 3.5 and 4.0.
Additional information regarding the extensions methods can be found here.
Hope you will find the prepared application and provided information useful.

Regards,
Damyan Bogoev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
A.
Top achievements
Rank 1
answered on 11 Oct 2010, 10:44 PM
Thanks for your reply.
I will look to yoursample application.Thanks.

Regards.
Tags
LINQ (LINQ specific questions)
Asked by
A.
Top achievements
Rank 1
Answers by
Damyan Bogoev
Telerik team
A.
Top achievements
Rank 1
Share this question
or