您好,我有一个类似这样的查询:
var queryGridData = from question in questions
select new {
i = question.Id,
cell = new List<string>() { question.Id.ToString(), question.Note, question.Topic }
};转换int所需的ToString()部件导致:
LINQ to Entities does not recognize the method 'System.String.ToString()' method, and this method cannot be translated into a store expression.嗯。我需要它作为string才能进入collection。有什么想法吗?
发布于 2011-08-05 14:39:18
我个人会在数据库中执行足够的查询来提供您想要的值,其余的在.NET中完成:
var queryGridData = questions.Select(q => new { q.Id, q.Note, q.Topic })
.AsEnumerable() // Do the rest locally
.Select(q => new { i = q.Id,
cell = new List<string> {
q.Id.ToString(),
q.Note,
q.Topic
} });(这种格式化很可怕,但希望在有更多空间的IDE中更容易做得更好:)
https://stackoverflow.com/questions/6952324
复制相似问题