Open genusP opened 6 years ago
Workaround, call ReturnsFromEntitySet when register function in EdmModel
@genusP - Can you provide a sample configuration, model, and controller?
//Build EDM
builder.EntityType<Task>().Collection.Function(nameof(Controllers.TasksController.Assigned));
assignedTaskFunc.ReturnsCollection<Task>();
assignedTaskFunc.Namespace = pluginNS;
//Entity
public partial class Task : ITargetAware
{
public int Id { get; set; }
public DateTime DateBegin { get; set; }
public DateTime? DateEnd { get; set; }
public Guid DirectionId { get; set; }
public string Text { get; set; }
public string TargetName { get; set; }
public int TargetId { get; set; }
public int? ParentId { get; set; }
public IEnumerable<Task> ChildTasks { get; set; }
public Task ParentTask { get; set; }
public IEnumerable<TaskStage> TaskStages { get; set; }
public IEnumerable<WorkReport> WorkReports { get; set; }
public IEnumerable<TaskStage> ActualStage { get; set; }
}
public partial class TaskStage
{
public int Id { get; set; }
public int TaskId { get; set; }
public int StageId { get; set; }
public DateTime SwitchDate { get; set; }
public bool Actual { get; set; }
public int? WorkReportId { get; set; }
public int? UserId { get; set; }
}
//Controller
public class TasksController:ControllerBase
{
[EnableQuery(HandleNullPropagation = Microsoft.AspNet.OData.Query.HandleNullPropagationOption.False)]
public IActionResult Assigned([FromServices] Services.ITasksStore store)
{
var employeeId = HttpContext.GetEmployee(e => e.Id);
var res = store.AssignedTasks(employeeId);
return new ObjectResult(res);
}
}
@genusP - Have you tried this with an earlier version of WebApi OData? I traced the code and repo'ed the issue but I'm not sure if it's a NetCore issue. Just trying to classify it properly.
@genusP we're currently reviewing open issues in preparation for our upcoming WebAPI 7.x release. Per Rob's comment, just so we can trace the problem down better, do you know if it's a problem existent in a WebAPI 6.x?
This issue exits on 6.x. I don't understand, why properties expand when build expression tree and not serialize to response. If this query option not support need error else serialize data.
Thanks for the feedback and the issue description. We will take this into consideration in further investigation.
If for EntityType not register EntitySet expand not work. For request
If entity CurrentTaskAssignment not register as EntitySet property Assignment not expand else work fine. Data selected from DB contains values for this properties.
I request this uri https://localhost:44346/api/Tasks/Satellite.AWT.Assigned?%24top=20&%24expand=ActualStage(%24select%3DStageId)&%24count=true
Executed expression contains Expand logic. In Respose No property ActualStage.