Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Commented Issue: Can't customize navigation link builder in ODataConventionModelBuilder [473]

$
0
0
For example, I want to change the navigation property link by providing my own link builder code:

public class Todo
{
public int Id { get; set; }
public Person CreatedBy { get; set; }
}
public class Person
{
public int PersonID { get; set; }
public string Name { get; set; }
}

var builder = new ODataConventionModelBuilder();
var todoes = builder.EntitySet<Todo>("Todo");
todoes.HasNavigationPropertiesLink(
todoes.EntityType.NavigationProperties,
(entityContext, navigationProperty) => new Uri(entityContext.UrlHelper.Link(ODataRouteNames.PropertyNavigation, new { Controller = "Todo", parentId = entityContext.EntityInstance.Id, NavigationProperty = navigationProperty.Name })));
return builder.GetEdmModel();

The code reports following error:

System.InvalidOperationException occurred
HResult=-2146233079
Message=No NavigationLink factory was found for the property 'CreatedBy' on entity set 'Todo'. Try calling HasNavigationPropertyLink on the EntitySetConfiguration.
Source=System.Web.Http.OData
StackTrace:
at System.Web.Http.OData.Builder.EntitySetLinkBuilderAnnotation.BuildNavigationLink(EntityInstanceContext context, IEdmNavigationProperty navigationProperty) in C:\dd\DevDiv\Offcycle\WPT\WebStackRuntime\runtime\src\System.Web.Http.OData\OData\Builder\EntitySetLinkBuilderAnnotation.cs:line 121
InnerException:

Comments: Introduce an extensibility point to allow user to modify the model before finally building the model.

Viewing all articles
Browse latest Browse all 7215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>