简体   繁体   English

微风不返回完整数据模型

[英]Breeze not returning full data model

Using Breeze with Entity Framework code first to return data from calls to a web service. 首先使用带有实体框架代码的Breeze将数据从调用返回到Web服务。

I have a data model that's several levels deep. 我有一个深层次的数据模型。 In this instance I'm returning a "schedule" object, which has a number of child "DefaultItems", each one of which has a cost and a single "type" child with its own properties. 在这种情况下,我将返回一个“计划”对象,该对象具有多个子级“ DefaultItems”,每个子级都有一个成本,并且有一个具有其自身属性的“类型”子级。

If you call the web service for one of these directly, you get something like this, which is as expected: 如果直接为其中之一调用Web服务,则将得到如下所示的预期结果:

{
   $id:"1",
   $type:"Schedule_06B188AC55B213FE4B13EA5B77D9C039007E80E9DB6F6841C055777A028C5F95, EntityFrameworkDynamicProxies-Core",
   DefaultItems:[
      {
         $id:"2",
         $type:"DefaultItem, Core",
         RowId:"d422af5d-d6ca-46a3-a142-1feb93348e1d",
         Cost:1,
         Type:{
            $id:"3",
            $type:"Type, Core",
            RowId:"38ed6d1b-d0b7-43cb-b958-2b2424b97759",
            Type:"Type1"
         },
         Schedule:{
            $ref:"1"
         }
      },
      //more DefaultItem objects
      {},
      {}
   ],
   RowId:"627eb2f2-ec74-4646-b3d1-d6423f84a2cd",
   Start:"2010-01-18T00:00:00.000",
   End:"2019-01-18T00:00:00.000"
}

This then comes down to the browser, where knockout is used to bind it to data objects. 然后将其归结到浏览器,在这里使用敲除功能将其绑定到数据对象。 The trouble is that at this point, the data only seems to be one level deep. 麻烦的是,此时,数据似乎只有一个深度。

So I can get at Schedule.Start and Schedule.End without issue. 这样我就可以毫无问题地到达Schedule.Start和Schedule.End。 I can also iterate through the DefaultItem objects inside my Schedule and get their Costs out. 我还可以遍历Schedule中的DefaultItem对象并获取其Costs。 But the Type objects inside DefaultItem just aren't there. 但是DefaultItem内的Type对象不存在。

It's not about using an incorrect name to bind them: if you pause in the browser debugger and drill down into the JSON that the browser has, there's no Type objects at all, not even empty objects where they should be. 这与使用不正确的名称绑定它们无关:如果您在浏览器调试器中暂停并深入浏览器所拥有的JSON,那么根本就没有Type对象,甚至根本没有空对象。

How come they come out of the web service, but don't seem to be in the data that Breeze passes back to the browser? 它们是如何从Web服务中出来的,但是似乎不在Breeze传递回浏览器的数据中?

Apparently in Breeze, relationships have to be defined both ways in order to propagate. 显然,在微风中,必须以两种方式定义关系才能传播。 So I had to ensure that my the primary key in my Type class was marked as a foreign key to the DefaultItem class. 因此,我必须确保将Type类中的主键标记为DefaultItem类的外键。

I believe this is currently registered as a bug. 我相信目前已将其注册为错误。 It's certainly a bit annoying. 这肯定有点烦人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM