In SQL Server table, one of the columne "question" has data type as "text".
Now, when i make query in sql then, use casting to varchar.
Now, in linq following is the query where retrieving specific result data.
The problem is, it gives me below error when i try to iterate result set in FOR
OR FOREACH
loop. I googled but, it says , that happen when do distinct but, i am not doing distinct operation.
The text data type cannot be selected as DISTINCT because it is not comparable
from t in db.Table
group t by new
{
t.Category,
t.Question
} into g
order by g.Category
select new
{
CategoryName = t.FirstOrDefault().Category, //might be required to handle null here
Question = t.FirstOrDefault().Question, //might be required to handle null here
TotalCount = t.Count(),
AnsLessEqual3 = t.Where(d => d.Answer<=3).Count(),
Ans5 = t.Where(d => d.Answer = 5).Count(),
Ans789 = t.Where(d => d.Answer = 7 || d.Answer = 8 || d.Answer = 9).Count()
}
Please guide how to fix this.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…