sdk/dotnet/src/Microsoft.Datasync.Client/Offline/Queue/TableOperation.cs
/// <summary>
/// Deserialize a record from the persistent store into a table operation.
/// </summary>
/// <param name="obj">The object to deserialize.</param>
/// <returns>The table operation represented by the object.</returns>
Deserialize a record from the persistent store into a table operation.
Deserialize a record from the persistent store into a table operation .
internal static TableOperation Deserialize(JObject obj)
        {
            if (obj == null)
            {
                return null;
            }
            var kind = (TableOperationKind)obj.Value<int>("kind");
            string tableName = obj.Value<string>("tableName");
            string itemId = obj.Value<string>("itemId");
            TableOperation operation = kind switch
            {
                TableOperationKind.Delete => new DeleteOperation(tableName, itemId),
                TableOperationKind.Insert => new InsertOperation(tableName, itemId),
                TableOperationKind.Update => new UpdateOperation(tableName, itemId),
                _ => throw new InvalidOperationException("Invalid operation kind")
            };
            if (operation != null)
            {
                operation.Id = obj.Value<string>(SystemProperties.JsonIdProperty);
                operation.Sequence = obj.Value<long?>("sequence").GetValueOrDefault();
                operation.Version = obj.Value<long?>("version").GetValueOrDefault();
                operation.JsonItem = obj.Value<string>("item");
                operation.State = (TableOperationState)obj.Value<int?>("state").GetValueOrDefault();
            }
            return operation;
        }
internal static TableOperation Deserialize ( JObject obj ) { if ( obj == null ) { return null ; } var kind = ( TableOperationKind ) obj . Value < int > ( " " ) ; string tableName = obj . Value < string > ( " " ) ; string itemId = obj . Value < string > ( " " ) ; TableOperation operation = kind switch { TableOperationKind . Delete => new DeleteOperation ( tableName , itemId ) , TableOperationKind . Insert => new InsertOperation ( tableName , itemId ) , TableOperationKind . Update => new UpdateOperation ( tableName , itemId ) , _ => throw new InvalidOperationException ( " " ) } ; if ( operation != null ) { operation . Id = obj . Value < string > ( SystemProperties . JsonIdProperty ) ; operation . Sequence = obj . Value < long ? > ( " " ) . GetValueOrDefault ( ) ; operation . Version = obj . Value < long ? > ( " " ) . GetValueOrDefault ( ) ; operation . JsonItem = obj . Value < string > ( " " ) ; operation . State = ( TableOperationState ) obj . Value < int ? > ( " " ) . GetValueOrDefault ( ) ; } return operation ; }
Deserialize a record from the persistent store into a table operation.
Deserialize a record from the persistent store into a table operation .
The table operation represented by the object.
The table operation represented by the object .
obj
JObject
The object to deserialize.
The object to deserialize .