BreezeManager不跟踪具有扩展属性的更改 [英] BreezeManager doesn't track changes with extended properties

查看:70
本文介绍了BreezeManager不跟踪具有扩展属性的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在客户端扩展了带有某些属性的服务器实体。
从查询中获取数据时,我实际上在结果中看到这些属性已填充正确的值。
当我更改扩展属性的值时,经理不会跟踪此更改。
当我调用manager.rejectChanges()时,没有任何动作发生,我调试了代码,尽管修改了该属性,但我看到了entityAspect.entityState( Unchaged)。
如果我修改了一个来自服务器实体的属性,那么一切正常。

I extended my server entity with some properties in the client side . When getting data from the query I really see these properties in the result filled with the proper values . When I change a value of an extended properties the manager doesn't track this change . When I call manager.rejectChanges() no action is happen , I debugged the code and I see in the entityAspect.entityState ("Unchaged") although I modified the property. If I modify a property comes from the server entity every thing is ok.

这是我在服务器中的Product实体:

Here is my Product entity in the server :

public class Product
{
    public string Code {get;set;}
}

I extended the product in the client side with some others :
var Product = function () {    
        this.kind = ko.observable();
    };

breeze.metadataStore.registerEntityTypeCtor("Product", Product);

查询后,我得到两个字段(Code,Kind),如果我更改Code,则实体状态为修改后,我可以调用manager.rejectChanges并使其生效,但是如果我进行更改,则什么也没有发生,则实体状态为已绑定。
知道为什么会这样吗?
预先感谢...

After the query I get both field (Code , Kind) , if I change Code , entity state is modified , I can call manager.rejectChanges and its takes effect, but if I change kind nothing happen , the entity state is "Unchaged". Any idea why this happen ? Thanks in advance ...

推荐答案

通过扩展,我假设您是指未映射的属性,这些属性通常在自定义构造函数中定义,如 扩展实体

By "extended" I assume you mean "unmapped" properties which are typically defined in a custom constructor as described in "Extending Entities"

未映射属性不会映射到服务器上永久存储的值。因此,对未映射属性的更改不会影响 EntityState ,并且不会将其发送到服务器。

"Unmapped" properties do not map to permanently stored values on the server. Therefore, changes to unmapped properties do not affect EntityState and they are not sent to the server.

请注意,服务器可以在查询的有效负载中提供未映射属性的值,Breeze会相应地设置未映射属性。这是一种在服务器上计算非持久值并将其传输到客户端上的实体的方法。

Note that the server can supply the value of an unmapped property in the payload of a query and Breeze will set the unmapped property accordingly. This is a way to calculate non-persisted values on the server and transmit them to the entity on the client.

在客户端上,未映射的属性在其他方面的行为类似于映射的属性:

On the client an unmapped property behaves in other respects like a mapped property:


  • 符合模型库的语法(例如,在KO模型中它是可观察的)

  • 导出时序列化

  • 验证规则适用

  • 提高 propertyChange 的时间值更改

  • 实体记住该属性的原始值

  • rejectChanges()还原将该属性恢复为原始值

  • conforms to the syntax of the model library (e.g., it becomes an observable in KO models)
  • serialized when exported
  • validation rules apply
  • raises propertyChange when the value is changed
  • entity remembers the property's "original value"
  • rejectChanges() reverts the property to that original value

这篇关于BreezeManager不跟踪具有扩展属性的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆