I created an abstract application controller class from which my controllers exit (as described in the next article )
Below is an example of what my code looks like
public abstract class ApplicationController : Controller
{
private ProjectDataContext datacontext = new ProjectDataContext();
protected ProjectDataContext DataContext
{
get { return datacontext; }
}
public ApplicationController()
{
ViewData["OpenTasks"] = DataContext.Tasks.Where(t => t.UserId == this.UserId).Count();
}
}
This results in the following error, which I determined due to the expression "Where" lamda:
If the controller does not have a factory controller, make sure it has an unsigned public constructor.
this error occurs regardless of how I write the LINQ query, and the only way to compile the application is to delete the Where clause as follows.
ViewData["OpenTasks"] = DataContext.Tasks.Count();
Any ideas what the problem is or how to solve it, since I need to execute a query against the user and not return all the records.
early
Mark