I have a OData V4
over Asp.net WebApi
(OWIN
).
Everything works great, except when I try to query a 4-level $expand
.
My query looks like:
http://domain/entity1($expand=entity2($expand=entity3($expand=entity4)))
I don't get any error, but the last expand isn't projected in my response.
More info:
- I've set the
MaxExpandDepth
to 10. - All my Entities are
EntitySets
. - I'm using the
ODataConventionModelBuilder
. - I've opened an SQL-profiler and could see that the query (and the result) is correct. It's some filter that occurs after the query is executed.
- I've searched the web and didn't find anything suitable.
- I've tried different entity 4 level
$expands
and they didn't work as well.
Edit:
I've overridden the OnActionExecuted
:
public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext) { base.OnActionExecuted(actionExecutedContext); var objectContent = actionExecutedContext.Response.Content as ObjectContent; var val = objectContent.Value; var t = Type.GetType("System.Web.OData.Query.Expressions.SelectExpandWrapperConverter, System.Web.OData"); var jc = Activator.CreateInstance(t) as JsonConverter; var jss = new JsonSerializerSettings(); jss.Converters.Add(jc); var ser = JsonConvert.SerializeObject(val, jss); }
The serialized value contains entity4.
I still have no idea what component removes entity4 in the pipe.
Edit #2:
I've create an adapter over DefaultODataSerializerProvider
and over all the other ODataEdmTypeSerializer's
. I see that during the process the $expand
for entity4 exists and when the ODataResourceSerializer.CreateNavigationLink
method is called on that navigationProperty (entity4) then it returns null.
I've jumped into the source code and I could see that the SerializerContext.Items
doesn't include the entity4 inside it's items and the SerializerContext.NavigationSource
is null.
To be specific with versions, I'm using System.Web.OData, Version=6.1.0.10907
.
0 comments:
Post a Comment