我运行这个查询
var myList = (from p in db.Full
where ((p.date_reception > begin & p.date_reception < end ) &
p.mc_host.Contains(host) & p.mc_host_class.Contains(hostClass))
group p by p.msg into g
orderby g.Count() descending
select new StringIntType
{
str = g.Key,
nbr = g.Count()
}).Take(20).ToList();
我得到这个错误:
text、ntext和image数据类型不能进行比较或排序,除非使用IS NULL或LIKE运算符。
有办法解决这个问题吗?
注意:msg
列的数据类型是DB中的文本。
我只是通过将数据库中的数据类型从text更改为varchar来解决这个问题通过使用cast(msg为varchar(max))msg