简体   繁体   English

Breeze.js getEntities不返回任何实体

[英]Breeze.js getEntities returns no entity

Using Breeze.js coupled with an Asp.net Web Api (with Entity Framework 6 Code First) I am unabled to get entities after a call to executeQuery(query). 使用Breeze.js加上Asp.net Web Api(使用Entity Framework 6 Code First),我无法在调用executeQuery(query)后获取实体。 More specifically here is my call in javascript: 更具体地说,这是我在javascript中的调用:

       entityManager.executeQuery(query)
           .then(function(data){
                 alert(data.results.length); // length > 0 --> has data !!
                 alert(entityManager.getEntities().length); // == 0 has no data WHY?!!
       }); 

while executeQuery(query) does hit my api controller on the server and returns data to client because data.results.length > 0 , it looks like data is not not cached because entityManager.getEntities().length == 0 . 虽然executeQuery(query)确实命中了服务器上的api控制器并将数据返回给客户端,因为data.results.length> 0 ,看起来数据不是因为entityManager.getEntities()。length == 0而没有缓存。 How then can I track changes if data is not cached? 如果没有缓存数据,我如何跟踪更改? Am I missing something? 我错过了什么吗? After googling around I found this post http://forum.ideablade.com/forum_posts.asp?TID=3739&title=entity-manager-cache-not-working where it is said that Simply put, Breeze requires that the models and dbcontext be in the same namespace. 谷歌搜索后我发现这篇文章http://forum.ideablade.com/forum_posts.asp?TID=3739&title=entity-manager-cache-not-working据说简单地说,Breeze要求模型和dbcontext是在同一名称空间中。 Is this the issue in play here? 这是问题吗? since I cannot change my namespaces (dbcontext and api controllers come from an external library I do not have control hover) what workaround could be used in this case? 因为我无法更改我的命名空间(dbcontext和api控制器来自外部库我没有控制悬停)在这种情况下可以使用哪些解决方法?

The most likely cause is that the objects returned by the server are not entity data ... at least not from the point of view of the Breeze client. 最可能的原因是服务器返回的对象不是实体数据...至少不是从Breeze客户端的角度来看。

Perhaps you can show us your query. 也许您可以向我们展示您的查询。

Check out the "Query Result Debugging" topic in the Breeze documentation. 查看Breeze文档中的“查询结果调试”主题

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

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