如何将 breeze 实体转换为 json

how to convert breeze entity to json

我知道这个问题以前有人问过,有一个非常古老的 post 有一些细节但是它已经过时了并且有人讨论将这个添加到 breeze。

我正在使用 angularJS 和一个不适用于 breeze 实体的 telerik 组件,我非常想将 breeze 实体查询列表转换为简单的 json 这样我就可以将它映射到我的组件。

我知道有人提到了 ko.toJs() 但我不使用敲除。有更好的方法吗?

谢谢

使用 noTracking EntityQuery 方法:

来自 breeze API 文档:

noTracking()

Returns a query with the 'noTracking' capability either enabled or disabled. With 'noTracking' enabled, the results of this query will not be coerced into entities but will instead look like raw javascript projections. i.e. simple javascript objects.

var query = new EntityQuery("Customers")
  .take(20)
  .orderBy("CompanyName")
  .noTracking(true);