WebAPI OData DTO

So I’ve started using OData in anger and pretty much immediately stumbled on a problem when using Data Transfer Objects (DTOs). This post explains that problem and the solution.

 

Problem

The following error is encountered when trying to access the exposed entity by key:

No routing convention was found to select an action for the OData path with template '~/entityset/key'.","type":""

 

image

 

Cause Code

OData configuration

Here I show the simple entity I’m exposing

image

 

Timesheet Controller

Here you can see that the underlying timesheets are just projected using Automapper to their DTO counterparts

image

 

Automapper config

Here I show the automapper configuration (not that it’s makes any difference to the problem encountered)

image

 

Solution

To fix this problem I needed to set the EntityType.Name property on my OData entity type.

image

 

And thereafter, success!

image
Comments are closed

Recent Tweets

Note: For Customization and Configuration, CheckOut Recent Tweets Documentation

Calendar

<<  February 2020  >>
MoTuWeThFrSaSu
272829303112
3456789
10111213141516
17181920212223
2425262728291
2345678

View posts in large calendar

Month List