I have something like this:
Func<Thread, bool> tmpFunc = thread => true;
threads = Threads.Where(tmpFunc).(...)
Now, when I do Threads.Where(thread => true).(...)
everything is okay, but using variable in .Where()
crashes my application. Why? Am I doing something wrong?
Okay, so here is the code that reproduces the error:
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();
And the error it gives me is internal .net framework data provider error 1025