I'm trying to populate a modal using AJAX. This is the method that returns the data I hope to populate the modal with but I get a red line under (x => x.tbProject == i)
and it says:
Delegate System.Func does not take 1 arguments.
Any ideas?
public partial class view_requests : System.Web.UI.Page
{
[WebMethod]
public static string getProjectByID(int id)
{
using (dbPSREntities4 myEntities = new dbPSREntities4())
{
var thisProject = myEntities.tbProjects.Where(x => x.tbProject == i).ToList();
JavaScriptSerializer serializer = new JavaScriptSerializer();
var json = serializer.Serialize(thisProject);
return json;
}
}
Hmm. It's not the error message I'd have expected, but I suspect the problem may be related to the fact that you're referring to i
within the lambda expression - and that's a variable which doesn't exist. That may be causing the compiler to get confused about which overload you're trying to use.
Try using
.Where(x => x.tbProject == id)
instead. Having said that, it's also odd that if you're querying myEntities.tbProjects
you need to use x.tbProject
... it would help if you'd give more details about your tbProjects
property and its type. (Following .NET naming conventions would be nice too.)
See more on this question at Stackoverflow