I've found that if you have a Get method decorated with the Queryable attribute it will fail with "navigation property not found" if the objects returned extend a base class with a List in it. I am just using plain objects. No Entity Framework. Ex:
public class Base
{
int Id {get; set;}
List<string> Links {get; set;}
}
public Company : Base
{
string Name { get; set;}
}
[Queryable]
public IQueryable<Company> Get()
{
...
}
The exception follow:
System.ArgumentException: The property does not belong to the specified type.
Parameter name: navigationProperty
at System.Web.Http.OData.Builder.EntityTypeConfiguration.AddNavigationProperty(PropertyInfo navigationProperty, EdmMultiplicity multiplicity)
at System.Web.Http.OData.Builder.ODataConventionModelBuilder.MapEntityType(IEntityTypeConfiguration entity)
at System.Web.Http.OData.Builder.ODataConventionModelBuilder.MapTypes()
at System.Web.Http.OData.Builder.ODataConventionModelBuilder.GetEdmModel()
at System.Web.Http.HttpActionDescriptorExtensions.<>c__DisplayClass1.<GetEdmModel>b__0(Object _)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at System.Web.Http.HttpActionDescriptorExtensions.GetEdmModel(HttpActionDescriptor actionDescriptor, Type entityClrType)
at System.Web.Http.QueryableAttribute.OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
at System.Web.Http.Filters.ActionFilterAttribute.CallOnActionExecuted(HttpActionContext actionContext, HttpResponseMessage response, Exception exception)
at System.Web.Http.Filters.ActionFilterAttribute.<>c__DisplayClass2.<System.Web.Http.Filters.IActionFilter.ExecuteActionFilterAsync>b__0(HttpResponseMessage response)
at System.Threading.Tasks.TaskHelpersExtensions.<>c__DisplayClass41`2.<Then>b__40(Task`1 t)
Comments: @lukepuplett: Did you try the packages from http://www.myget.org/F/aspnetwebstacknightly/ ?
public class Base
{
int Id {get; set;}
List<string> Links {get; set;}
}
public Company : Base
{
string Name { get; set;}
}
[Queryable]
public IQueryable<Company> Get()
{
...
}
The exception follow:
System.ArgumentException: The property does not belong to the specified type.
Parameter name: navigationProperty
at System.Web.Http.OData.Builder.EntityTypeConfiguration.AddNavigationProperty(PropertyInfo navigationProperty, EdmMultiplicity multiplicity)
at System.Web.Http.OData.Builder.ODataConventionModelBuilder.MapEntityType(IEntityTypeConfiguration entity)
at System.Web.Http.OData.Builder.ODataConventionModelBuilder.MapTypes()
at System.Web.Http.OData.Builder.ODataConventionModelBuilder.GetEdmModel()
at System.Web.Http.HttpActionDescriptorExtensions.<>c__DisplayClass1.<GetEdmModel>b__0(Object _)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at System.Web.Http.HttpActionDescriptorExtensions.GetEdmModel(HttpActionDescriptor actionDescriptor, Type entityClrType)
at System.Web.Http.QueryableAttribute.OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
at System.Web.Http.Filters.ActionFilterAttribute.CallOnActionExecuted(HttpActionContext actionContext, HttpResponseMessage response, Exception exception)
at System.Web.Http.Filters.ActionFilterAttribute.<>c__DisplayClass2.<System.Web.Http.Filters.IActionFilter.ExecuteActionFilterAsync>b__0(HttpResponseMessage response)
at System.Threading.Tasks.TaskHelpersExtensions.<>c__DisplayClass41`2.<Then>b__40(Task`1 t)
Comments: @lukepuplett: Did you try the packages from http://www.myget.org/F/aspnetwebstacknightly/ ?