简体   繁体   English

__updatedAt未更新:Azure移动服务

[英]__updatedAt not updated: Azure Mobile Services

Azure Mobile Services is not updated the __updatedAt field when rows are updated. 行更新时,Azure移动服务未更新__updatedAt字段。 This is supposed to happen automatically. 这应该是自动发生的。 Is there anything that can be done to fix this? 有什么可以解决的方法吗? It was working automatically before, I don't know what could have possibly changed recently. 它以前是自动运行的,我不知道最近可能会发生什么变化。

I'm working in Android. 我正在使用Android。

When you create a table using the Mobile Service Azure Portal, it creates a trigger on the table that updates the __updatedAt column whenever a row is created or updated. 使用Mobile Service Azure门户创建表时,它会在表上创建一个触发器,该触发器将在创建或更新行时更新__updatedAt列。 The DDL for the trigger looks like this: 触发器的DDL如下所示:

CREATE TRIGGER [(schema)].[TR_(table)_InsertUpdateDelete] ON [(schema)].[(table)]
WITH EXECUTE AS CALLER
AFTER INSERT, UPDATE, DELETE
AS
    BEGIN
        SET NOCOUNT ON;
        IF TRIGGER_NESTLEVEL() > 3 RETURN;

        UPDATE [(schema)].[(table)] SET [(schema)].[(table)].[__updatedAt] = CONVERT (DATETIMEOFFSET(3), SYSUTCDATETIME())
        FROM INSERTED
        WHERE INSERTED.id = [(schema)].[(table)].[id]
    END

The above is for Mobile Services. 以上是针对移动服务的。 The newer Mobile Apps Easy Tables are slightly different: the column is named updatedAt without the __, and they use DATETIMEOFFSET(9) instead of (3). 较新的Mobile Apps Easy Tables稍有不同:该列名为updateAt,不带__,并且它们使用DATETIMEOFFSET(9)而不是(3)。

Is the field not being updated in the database or in the client app? 数据库或客户端应用程序中的字段是否未更新? If it's the database, that means that someone has changed a SQL trigger, since that is what sets the field to change. 如果是数据库,则意味着有人更改了SQL触发器,因为这是更改字段的原因。

If it's the mobile client, note that __updatedAt is only sent to the client after the response has come from the server. 如果是移动客户端,请注意__updatedAt仅在服务器收到响应后才发送给客户端。 So, if you're using offline sync, it will be once you do a PushAsync. 因此,如果您使用的是离线同步功能,则只需执行一次PushAsync。 If you're using the online tables, it will be in the modified object after the call to UpdateAsync. 如果您正在使用在线表,则在调用UpdateAsync之后,该表将位于修改后的对象中。

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

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