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_开发者_C百科NAME"].ToString() & gradeRow.Field<string>("EXG_GRADE_NAME").First() ;
also. But Still i get same error.
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();
make that var gradeValue as List gradeValue
精彩评论