Webapi: navigation property in a complex type

Created on 12 Jan 2015  路  17Comments  路  Source: OData/WebApi

Consider support navigation property (at least non-contained nav prop, since
contained nav prop is not supported by ODL yet) in a complex type.

                    // navigation property in a complex type ?
                    if (mappedType == null)
                    {
                        // the user told nothing about this type and this is the first time we are seeing this type.
                        // complex types cannot contain entities. So, treat it as complex property.
                        MapStructuralProperty(complexType, property, PropertyKind.Complex, isCollection);
                    }
                    else if (_explicitlyAddedTypes.Contains(mappedType))
                    {
                        // user told us that this is an entity type.
                        throw Error.InvalidOperation(SRResources.ComplexTypeRefersToEntityType, complexType.ClrType.FullName, mappedType.ClrType.FullName, property.Name);
                    }
                    else
                    {
                        // we tried to be over-smart earlier and made the bad choice. so patch up now.
                        EntityTypeConfiguration mappedTypeAsEntity = mappedType as EntityTypeConfiguration;
                        Contract.Assert(mappedTypeAsEntity != null);

                        ReconfigureEntityTypesAsComplexType(new EntityTypeConfiguration[] { mappedTypeAsEntity });

                        MapStructuralProperty(complexType, property, PropertyKind.Complex, isCollection);
                    }

Work Item Details

Original CodePlex Issue: Issue 1765
Status: Proposed
Reason Closed: Unassigned
Assigned to: Unassigned
Reported on: Mar 17, 2014 at 2:20 PM
Reported by: cysu
Updated on: Apr 17, 2014 at 10:54 AM
Updated by: zjufish

P1 backlog feature

Most helpful comment

vote for adding this feature

All 17 comments

vote for adding this feature

Any updates on adding this into a new release?

+1

see the initial design spec: http://odata.github.io/odata.net/#07-03-NavigationProperty-In-ComplexType

+1

+1

Definitely +1

+1

Absolutely + 1

Please :) +1

+1

+1

This is a critical feature for us. Can it be fixed ASAP?

@santhudr @Asido @MaxOverDev @SeanSafken @Catchops @zfkingth @sebekz @rbonini @Casimodo72 ...

In Web API OData v6.0.0 release, we supports the functionality of this feature. See detail at:
https://github.com/OData/WebApi/releases/tag/v6.0.0

You can try the latest package on nuget.org as: https://www.nuget.org/packages/Microsoft.AspNet.OData/6.1.0

We'd love to get any feedback from you.

Thanks!

I've updated the package to 6.1.0. I'm trying to expand on the NavigationProperty of a ComplexType and I am getting this error:

{
"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.ODataException",
"stacktrace": " at System.Web.OData.Formatter.Serialization.SelectExpandNode.ValidatePathIsSupported(ODataPath path)\r\n at System.Web.OData.Query.Expressions.SelectExpandBinder.GetPropertiesToExpandInQuery(SelectExpandClause selectExpandClause)\r\n at System.Web.OData.Query.Expressions.SelectExpandBinder.ProjectElement(Expression source, SelectExpandClause selectExpandClause, IEdmEntityType entityType, IEdmNavigationSource navigationSource)\r\n at System.Web.OData.Query.Expressions.SelectExpandBinder.GetProjectionLambda()\r\n at System.Web.OData.Query.Expressions.SelectExpandBinder.Bind(Object entity)\r\n at System.Web.OData.Query.SelectExpandQueryOption.ApplyTo(Object entity, ODataQuerySettings settings)\r\n at System.Web.OData.Query.ODataQueryOptions.ApplySelectExpandT\r\n at System.Web.OData.Query.ODataQueryOptions.ApplyTo(Object entity, ODataQuerySettings querySettings)\r\n at System.Web.OData.EnableQueryAttribute.ExecuteQuery(Object response, HttpRequestMessage request, HttpActionDescriptor actionDescriptor, ODataQueryContext queryContext)\r\n at System.Web.OData.EnableQueryAttribute.OnActionExecuted(HttpActionExecutedContext actionExecutedContext)"
}}

The URL is: odata/v1/Reports(1)?$expand=ReportTargets/ReportTargetLookup
Where ReportTarget is a ComplexType and ReportTargetLookup is a Navigational Property.
Model structure is:

Class Report
{
...
public List\ ...
}

Class ReportTarget
{
...
public ReportTargetLookup ReportTargetLookup{get;set;}
...
}

Am I missing something?

@santhudr No, you didn't.

So far, Complex type with Navigation property only supports to create the metadata, for example:

image

That's why this issue still opens.

It should support after https://github.com/OData/WebApi/pull/1738. Please open new issue if you have further concerns. Thanks.

Was this page helpful?
0 / 5 - 0 ratings