Quantcast
Channel: systemsabuse.com
Viewing all articles
Browse latest Browse all 14

Azure App Service: Offline Sync – Do not use CreatedAt for Display

0
0

In the Azure App Service Mobile Client Offline Sync:

With offline sync, the CreatedAt field for a new record that has not been synced is null. If you set CreatedAt to DateTime.Now or another value, on sync, CreatedAt will be replaced with the DateTime of when the sync occurred (used for incremental syncs among other things). If you need to have a created time that corresponds to the actual time the user created the record, created your own property, say DateUTC, and set it yourself to DateUTC.Now;. This value will not change. The only concern with doing this is if the user somehow has the date wrong on their device, the DateUTC will be wrong as well. Hopefully everyone has figured out that having their device date/time set automatically is a good thing.

//setting the object
        var customObject = new CustomObject
        {
            DateUTC = DateTime.UtcNow,
        };

//to display it in the local time
        [JsonIgnore]
        public string DateDisplay { get { return DateUTC.ToLocalTime().ToString("d"); } }

        [JsonIgnore]
        public string TimeDisplay { get { return DateUTC.ToLocalTime().ToString("t"); } }


Viewing all articles
Browse latest Browse all 14

Latest Images

Trending Articles





Latest Images