linq中将int型转换为string型
怎么转换?
我写的代码:
ViewData["name"] = ts.GetList().Select(m => new SelectListItem { Text = m.TypeName,Value=m.ID }).ToList();
红颜色那里报:无法将Int型转换为string型。
我直接tostring(),运行的时候报
异常详细信息: System.NotSupportedException: LINQ to Entities 不识别方法“System.String ToString()”,因此该方法无法转换为存储表达式
请高手指点迷津,谢谢。
[解决办法]
ts.GetList().ToList().Select...
[解决办法]
ViewData["name"] = ts.GetList().Select(m => new SelectListItem { Text = m.TypeName,Value=m.ID }).ToList();
m.id 是不是int 型?,改写为m.id.toString() 就可以了
[解决办法]