Kuntady Nithesh
Kuntady Nithesh

Reputation: 11731

Can any one solve this Linq error -?

I wrote the query like this

 var gradeValue = from DataRow gradeRow in GraceTable.Rows
                             let marksAbove = gradeRow.Field<decimal>("EXG_MARKS_ABOVE") 
                             let marksBelow = gradeRow.Field<decimal>("EXG_MARKS_BELOW")
                             where obtMarksRow.Field<decimal>("Percentage") >= marksAbove && obtMarksRow.Field<decimal>("Percentage") <= marksBelow
                             select gradeRow.Field<string>("EXG_GRADE_NAME");

but i am getting the value (gradeValue.ToString() ) as

"System.Linq.Enumerable+WhereSelectEnumerableIterator`2[System.Data.DataRow,System.String]"

Whats wrong ?

i tried select gradeRow["EXG_GRADE_NAME"].ToString() & gradeRow.Field<string>("EXG_GRADE_NAME").First() ; also. But Still i get same error.

Upvotes: 2

Views: 4215

Answers (2)

Anup Pandey
Anup Pandey

Reputation: 15

make that var gradeValue as List gradeValue

Upvotes: 0

JaredPar
JaredPar

Reputation: 755457

The problem is that gradeValue is an enumeration which is a collection of values. It appears that you expect it to be a single value or want the display for the first item in the collection. If so then do the following

gradeValue.First().ToString();

Upvotes: 11

Related Questions