在客户端实体中更改了哪些属性

时间:2011-11-10 02:34:32

标签: silverlight ria

我正在使用silverlight 4运行RIA服务。

我有RIA服务实体,派生自这个类,

System.ServiceModel.DomainServices.Client.Entity

当它们未被更改时,它们被标记为已更改(使用HasChanges字段或EntityState字段)。我需要一种更可靠的方法来确定我的哪些实体已经改变。

原因是我的实体上有三个文本字段,纯文本字段,富文本字段和HTML字段。它们都与同一文本相关联。在我的编辑器控件中显示它们会巧妙地修改富文本和HTML字段,但不会修改纯文本字段。

所以我想理想地做这样的事情,

'实体是否具有HTML或Rich Text字段以外的任何修改字段

纯文本字段将获取用户对文本进行的“实际”更改。

Entity基类上有一些名为“ModifiedProperties”和“OriginalValues”的非公共成员,如果有办法使用它们会是理想的吗?

1 个答案:

答案 0 :(得分:0)

好的,仔细检查我正在使用的富文本控件不支持绑定。这意味着在代码中有类似的东西,

public void LoadText() // loads from the database and puts into the UI control
{
    control.RichText = entity.RichText;
    control.Html = entity.Html;
    control.Body = entity.Body;
}

public void UpdateText() // update the entity with the updated text
{
    entity.RichText = control.RichText;
    entity.Html = control.Html;
    entity.Body = control.Body;
}

我正在使用第三方控件Liquid.RichTextBlock。事实证明,即使文本没有被编辑,此控件在某些情况下也会返回不同的RichText和HTML。这可能与可调整大小的弹出窗口上的控件宽度有关。

Liquid.RichTextBlock控件有一个名为' History'我实际上可以使用该属性告诉我用户是否实际更新了文本。

原则上是这样的,

public void UpdateText() // update the entity with the updated text
{
    if (control.History.Count > 0) // the user has updated the format and or the text
    {
        entity.RichText = control.RichText;
        entity.Html = control.Html;
        entity.Body = control.Body;
    }
}
相关问题