You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is admittedly my first attempt to use L2Q, but I am getting an unfathomable error!
I am using Web Api (1.0) and Entity Framework (5.something).
I have a relatively simple object:
public class AgentTask
{
public int Id { get; set; }
public Guid AgentId { get; set; }
public Guid PropertyId { get; set; }
public TaskType Type { get; set; }
public TaskStatus Status { get; set; }
public Guid CreatedBy { get; set; }
public DateTime CreatedDate { get; set; }
public DateTime? SlaDeadline { get; set; }
public DateTime? UpdatedDate { get; set; }
public virtual Property Property { get; set; }
}
In my DbContext, I have a set of these:
public IDbSet<AgentTask> AgentTasks { get; set; }
I have a service layer that runs a simple query against this set:
[HttpGet]
[LinqToQueryable]
public IQueryable<TaskViewModel> GetIncompleteTasks()
{
var loggedUser = _authenticator.GetUserId();
if (loggedUser != null)
{
var result = _agentTaskListService.GetIncompleteTasks(loggedUser.Value);
return result.AsQueryable();
}
throw new ArgumentException("Not Found");
}
I am calling my controller using a jQuery Ajax GET request. The url ends:
{
"message": "An error has occurred.",
"exceptionMessage": "The action 'GetIncompleteTasks' on controller 'AgentListing' with return type 'System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' cannot support querying. Ensure the type of the returned content is IEnumerable, IQueryable, or a generic form of either interface.",
"exceptionType": "System.InvalidOperationException",
"stackTrace": " at System.Web.Http.QueryableAttribute.ValidateReturnType(Type responseContentType, HttpActionDescriptor actionDescriptor)\r\n at System.Web.Http.QueryableAttribute.OnActionExecuted(HttpActionExecutedContext actionExecutedContext)\r\n at System.Web.Http.Filters.ActionFilterAttribute.CallOnActionExecuted(HttpActionContext actionContext, HttpResponseMessage response, Exception exception)\r\n at System.Web.Http.Filters.ActionFilterAttribute.<>c__DisplayClass2.<System.Web.Http.Filters.IActionFilter.ExecuteActionFilterAsync>b__0(HttpResponseMessage response)\r\n at System.Threading.Tasks.TaskHelpersExtensions.<>c__DisplayClass41`2.<Then>b__40(Task`1 t)\r\n at System.Threading.Tasks.TaskHelpersExtensions.ThenImpl[TTask,TOuterResult](TTask task, Func`2 continuation, CancellationToken cancellationToken, Boolean runSynchronously)"
}
I can put a breakpoint on the line return result.AsQueryable(); in the controller method, and it hits it fine.
Any suggestions as to what I've done wrong?
The text was updated successfully, but these errors were encountered:
Hey thanks for the extra info. From the stack trace it looks like the Web API Queryable attribute/message handler is getting invoked somewhere along the line... is it possible that you've got this set up as a global filter in Webapiconfig.cs?
Basically this is the web api odata handler... so it's trying to process a response that has already been processed by linq to querystring and hence throwing an error.
This is admittedly my first attempt to use L2Q, but I am getting an unfathomable error!
I am using Web Api (1.0) and Entity Framework (5.something).
I have a relatively simple object:
In my DbContext, I have a set of these:
I have a service layer that runs a simple query against this set:
And this is called by my controller method:
I am calling my controller using a jQuery Ajax GET request. The url ends:
I get the following exception:
I can put a breakpoint on the line return result.AsQueryable(); in the controller method, and it hits it fine.
Any suggestions as to what I've done wrong?
The text was updated successfully, but these errors were encountered: