What's wrong with my LINQ expression?

C

Curious

I have a variable "dataTable" that is of type System.Data.DataTable.
It has three columns, CCy, Point, and Book.

I want to get all of the records with the restriction of their column
"CCy" being of value "ARS". Therefore, I have the following LINQ
statement:

var smallTable =
from d in dataTable
where d.Columns["CCy"] = "ARS"
select new
{
Point =
d.Columns["Point"],
Book =
d.Columns["Book"]
};

Even before I compile, several texts are highlighted in red color so I
know it won't compile. For instance, "where" is highlighted in red
with tooltip message "Cannot resolve symbol 'Where'".
Also, all of the "Columns" are highlighted in red with tooltip message
"Cannot resolve symbol 'Columns'"

What's wrong with the statement? How to fix it?
 
C

Curious

I have a variable "dataTable" that is of type System.Data.DataTable.
It has three columns, CCy, Point, and Book.

I want to get all of the records with the restriction of their column
"CCy" being of value "ARS". Therefore, I have the following LINQ
statement:

        var smallTable =
                                from d indataTable
                                where d.Columns["CCy"] = "ARS"
                                select new
                                           {
                                               Point =
d.Columns["Point"],
                                               Book =
d.Columns["Book"]
                                           };

Even before I compile, several texts are highlighted in red color so I
know it won't compile. For instance, "where" is highlighted in red
with tooltip message "Cannot resolve symbol 'Where'".
Also, all of the "Columns" are highlighted in red with tooltip message
"Cannot resolve symbol 'Columns'"

What's wrong with the statement? How to fix it?

FYI, "where" is ok now (its color is blue in Visual Studio), after
I've made the following change:

from d in dataTable ===========> from d in dataTable..AsEnumerable()

But I still have the three "Columns" in red!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top