4

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.

JumpingJezza
  • 5,498
  • 11
  • 67
  • 106
user1421676
  • 61
  • 1
  • 1
  • 4

3 Answers3

22

Have you tried adding the System.Data.DataSetExtensions dll to your project?

JumpingJezza
  • 5,498
  • 11
  • 67
  • 106
0

To complete the previous answer, in case you can not add the reference to System.Data.DataSetExtensions using Visual Studio, I managed to do it by manually editing the library project file directly. Just insert the proper line among the existing references:

<Reference Include="System.Data" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Runtime.Remoting" />
rukimira
  • 66
  • 5
0

Use DataTable instead of DataSet

In your code change to:

DataTable ds = new DataTable();
David Buck
  • 3,752
  • 35
  • 31
  • 35