【发布时间】:2015-01-26 01:35:20
【问题描述】:
我正在调用 OData V3 WebApi,扩展一些相关实体如下:
var cenarioInvestimentoEscolhido = Container.CenarioDeInvestimentoEscolha.Expand("CenarioDeInvestimentoCenario,CenarioDeInvestimentoCenario/Cenario,CenarioDeInvestimentoCenario/Aeronave").Where(c => c.CenarioDeInvestimentoCenario.CenarioDeInvestimento.Aerodromo.CodigoIcao.Equals(idAerodromo)).SingleOrDefault();
这是表达式生成的绝对 URI:
https://localhost/SAC/WebAPI/ODataWebApi/CenarioDeInvestimentoEscolha()?$filter=CenarioDeInvestimentoCenario/CenarioDeInvestimento/Aerodromo/CodigoIcao%20eq%20'SNBR'&$top=2&$expand=CenarioDeInvestimentoCenario,CenarioDeInvestimentoCenario/Cenario,CenarioDeInvestimentoCenario/Aeronave
这是 API 响应的结果集:
{
"odata.metadata":"https://localhost/SAC/WebAPI/ODataWebApi/$metadata#CenarioDeInvestimentoEscolha","value":[
{
"CenarioDeInvestimentoCenario":{
"Aeronave":{
"Id":4,"Codigo":"B738","Nome":"737-800","IdFabricante":3,"Pmd":"80-90%","Categoria":"4C"
},"Cenario":{
"Id":3,"Nome":"Cen\u00e1rio 3"
},"IdAerodromo":112,"IdCenario":3,"IdAeronave":4,"CategoriaDeAeronave":"4C","Subtotal":"39587651.01","EventualAcrescimo":"3958765.10","Total":"43546416.11"
},"IdAerodromo":112,"IdCenario":3,"DataInformadoBancoBrasil":"2014-03-11T00:00:00","NumeroOficio":"46/2014/SEAP/SAC-PR","DataEscolhaSalaMonitoramento":"2014-03-17T00:00:00","DataEscolhaSacpr":"2014-03-18T00:00:00"
}
]
}
如您所见,有一个名为 CenarioDeInvestimentoCenario 的实体与相关实体 Aeronave 和 Cenario。 但是,在此调用之后,两个子实体都为 null,就好像它们没有被反序列化一样。
我已经在 ReceivingResponse 事件中检查了响应流,并且确实已经收到了相关信息。为什么这些属性为空?这是一些序列化问题吗?
【问题讨论】:
标签: odata asp.net-web-api wcf-data-services