G
Gani tpt
Guest
I have employee table and his marks.
I just want to get nearest rank based on the parameter using LINQ C#.
below is example:
double GradeValue = 17.00; ==> value 17.00 is not in the Grade List. But, it will go the nearest value to match in the grade
column. so the nearest value is 17.15
For Grade 17.15 ==> Corresponding Rank is 0.375 (Final Rank Output is = 0.375)
datatable
I have written below LINQ Query. But, i want to find the nearest value.
Rank = (dtEmp.AsEnumerable().Where(p => p.Field<double>("Grade") == GradeValue).Select(p => p.Field<double>("Rank"))).FirstOrDefault();
Final Rank Output is = 0.375
How to Modify the existing LINQ query or some other method..
Note : we need to handle the null values in the column of "Grade". otherwise getting DBNull value error.
Continue reading...
I just want to get nearest rank based on the parameter using LINQ C#.
below is example:
double GradeValue = 17.00; ==> value 17.00 is not in the Grade List. But, it will go the nearest value to match in the grade
column. so the nearest value is 17.15
For Grade 17.15 ==> Corresponding Rank is 0.375 (Final Rank Output is = 0.375)
datatable
I have written below LINQ Query. But, i want to find the nearest value.
Rank = (dtEmp.AsEnumerable().Where(p => p.Field<double>("Grade") == GradeValue).Select(p => p.Field<double>("Rank"))).FirstOrDefault();
Final Rank Output is = 0.375
How to Modify the existing LINQ query or some other method..
Note : we need to handle the null values in the column of "Grade". otherwise getting DBNull value error.
Continue reading...