我有一个模型,我有一个项目(根),然后是一个复杂的类型(制造),嵌入另一个复杂类型(位置,名为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包:
此致 NicolasStübi