1

Closed

Nested class is not supported by QueryableAttribute

description

To repro:

public class Parent
{
public class Nest
{
    public string Name { get; set; }
}
]

Put Nest as action return type:
[QueryableAttribute]
public IEnumerable<Nest> Get()

Throw following exception:

System.InvalidOperationException occurred
Message=No EntitySet exists in the EdmModel with EntityClrType 'MvcWebApi.ODataTests.Models.Order+NestClass'.
Source=System.Web.Http.OData
StackTrace:
   at System.Web.Http.OData.ODataQueryContext..ctor(IEdmModel model, Type entityClrType) in C:\dd\DevDiv\Offcycle\WPT\WebStackRuntime\runtime\src\System.Web.Http.OData\OData\ODataQueryContext.cs:line 65
InnerException:
Closed Oct 18, 2012 at 10:28 PM by hongyes
No longer repro in latest build

comments

gforce0803 wrote Aug 24, 2012 at 8:07 PM

The root issue here looks to be that your entity hasn't got a property which is make with the [Key] attribute.
I've found that if you don't have a [Key] on the entity then odata won't play.

Regards
Grahame

youssefm wrote Oct 17, 2012 at 10:36 PM

Unable to repro this issue with or without a Key property. This may have been fixed already.