-2

I'm currently learning LINQ to SQL where I am selecting a data from the LINQ table object through datacontext.

I have created a datacontext by adding linqtosql class and dragged the HH_table.

The problem I'm facing is the LINQ namespace is not recognized by the program.

using (var connection = new DataClasses1DataContext())
{
   var g = from a in HH_table select a.date;
}

In the above code i'm getting a error that:

cannot resolve symbol 'select'.

I have added all the references with respect to LINQ

    System.Data.linq
    System.core,
    System.xml.linq
    System.Linq;

but none of the references solve the above problem.

Am I missing something?

Ramji
  • 375
  • 2
  • 14

2 Answers2

2

You omitted the data context just before HH_table. Notice I renamed connection to context, just because that better reflects what it is.

using (var context = new DataClasses1DataContext())
{
    var g = from a in context.HH_table select a.date;
}
Bouke
  • 1,531
  • 1
  • 12
  • 21
0

Have you tried System.Linq?

If you have errors like "cannot resolve System.Linq", check your .NET Framework version. System.Linq was introduced on .NET Framework 3.5.

In visual studio, Go to Project -> Properties -> Application and check the "Target Framework" property. It's probably a target framework prior to 3.5.

also, you still may have problems because of HH_Table. if HH_Table is a table of your "connection" context, use "connection.HH_Table" instead.

AMK6610
  • 1
  • 3