我有这样的事情:
Func<Thread, bool> tmpFunc = thread => true;
threads = Threads.Where(tmpFunc).(...)
现在,当我做Threads.Where(thread => true).(...)
的一切都很好,但是在我的应用程序中使用变量时会.Where()
崩溃。为什么?难道我做错了什么?
好的,这是重现错误的代码:
var threads = context.Categories
.Where(c => c.Name == variable)
.Select(c => new
{
threads = c.Threads
.Where(tmpFunc)
.OrderByDescending(t => t.DateCreated)
.Skip(threadsToSkip)
.Take(threadsPerPage)
.Select(t => new
{
t,
CategoryName = t.Category.Name,
AuthorName = t.Author.UserName,
t.Posts.Count,
LastPost = t.Posts
.OrderByDescending(post => post.DateCreated)
.Select(p => new{p.Author.UserName, p.DateCreated})
.FirstOrDefault()
}),
c.Threads.Count
}).Single();
它给我的错误是内部 .net 框架数据提供程序错误 1025