odata v4 не может выбрать свойство сложного типа в другом сложном типе (используя раскрытие)
У меня есть модель, в которой у меня есть Items (root), затем сложный тип (Manufacturing), встраивающий другой сложный тип (местоположение, названное ниже Factory).
При расширении производства все работает как положено:
https://localhost/Inextrace/Items('ABC123456789')?$select=Code&$expand=Manufacturing($select=Factory)
Однако, когда я пытаюсь выбрать только одно свойство местоположения сложного типа (Factory), оно говорит, что оно не поддерживается. Любое решение для достижения этой цели?
https://localhost/Inextrace/Items('ABC123456789')?$select=Code&$expand=Manufacturing($select=Factory/Code)
Отклик:
{
"error":{
"code":"","message":"The query specified in the URI is not valid. A path within the select or expand query option is not supported.","innererror":{
"message":"A path within the select or expand query option is not supported.","type":"Microsoft.OData.Core.ODataException","stacktrace":" at System.Web.OData.Formatter.Serialization.SelectExpandNode.ValidatePathIsSupported(ODataPath path)\r\n at System.Web.OData.Query.Expressions.SelectExpandBinder.GetPropertiesToIncludeInQuery(SelectExpandClause selectExpandClause, IEdmEntityType entityType, IEdmEntitySet entitySet, IEdmModel model, ISet`1& autoSelectedProperties)\r\n at System.Web.OData.Query.Expressions.SelectExpandBinder.ProjectElement(Expression source, SelectExpandClause selectExpandClause, IEdmEntityType entityType, IEdmEntitySet entitySet)\r\n at System.Web.OData.Query.Expressions.SelectExpandBinder.BuildPropertyContainer(IEdmEntityType elementType, Expression source, Dictionary`2 propertiesToExpand, ISet`1 propertiesToInclude, ISet`1 autoSelectedProperties, Boolean isSelectingOpenTypeSegments)\r\n at System.Web.OData.Query.Expressions.SelectExpandBinder.ProjectElement(Expression source, SelectExpandClause selectExpandClause, IEdmEntityType entityType, IEdmEntitySet entitySet)\r\n at System.Web.OData.Query.Expressions.SelectExpandBinder.GetProjectionLambda()\r\n at System.Web.OData.Query.Expressions.SelectExpandBinder.Bind(IQueryable queryable)\r\n at System.Web.OData.Query.SelectExpandQueryOption.ApplyTo(IQueryable queryable, ODataQuerySettings settings, IAssembliesResolver assembliesResolver)\r\n at System.Web.OData.Query.ODataQueryOptions.ApplySelectExpand[T](T entity, ODataQuerySettings querySettings)\r\n at System.Web.OData.Query.ODataQueryOptions.ApplyTo(IQueryable query, ODataQuerySettings querySettings)\r\n at System.Web.OData.EnableQueryAttribute.ExecuteQuery(Object response, HttpRequestMessage request, HttpActionDescriptor actionDescriptor)\r\n at System.Web.OData.EnableQueryAttribute.OnActionExecuted(HttpActionExecutedContext actionExecutedContext)"
}
}
}
Есть идеи выбрать только какое-то поле фабрики?
Я использую C# .Net и следующие версии пакетов nuget:
- Microsoft.AspNet.OData v5.8.0
- Microsoft.OData.Code v6.14.0
- Microsoft.AspNet.WebApi v5.2.3
С уважением, Николас Стюби