简体   繁体   中英

__updatedAt not updated: Azure Mobile Services

Azure Mobile Services is not updated the __updatedAt field when rows are updated. 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.

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. The DDL for the trigger looks like this:

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).

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.

If it's the mobile client, note that __updatedAt is only sent to the client after the response has come from the server. So, if you're using offline sync, it will be once you do a PushAsync. If you're using the online tables, it will be in the modified object after the call to UpdateAsync.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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