sdk/dotnet/src/Microsoft.Datasync.Client/Offline/SyncContext.cs
/// <summary>
/// Inserts an item into the offline table.
/// </summary>
/// <param name="tableName">The name of the offline table.</param>
/// <param name="instance">The instance to insert into the table.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> to observe.</param>
/// <returns>A task that returns the inserted data when complete.</returns>
Inserts an item into the offline table.
Inserts an item into the offline table .
public async Task InsertItemAsync(string tableName, JObject instance, CancellationToken cancellationToken = default)
        {
            EnsureContextIsInitialized();
            string itemId = ServiceSerializer.GetId(instance, allowDefault: true);
            if (itemId == null)
            {
                itemId = IdGenerator?.Invoke(tableName) ?? Guid.NewGuid().ToString("N");
                instance = (JObject)instance.DeepClone();
                instance[SystemProperties.JsonIdProperty] = itemId;
            }
            var operation = new InsertOperation(tableName, itemId);
            await EnqueueOperationAsync(operation, instance, cancellationToken).ConfigureAwait(false);
        }
public async Task InsertItemAsync ( string tableName , JObject instance , CancellationToken cancellationToken = default ) { EnsureContextIsInitialized ( ) ; string itemId = ServiceSerializer . GetId ( instance , allowDefault : true ) ; if ( itemId == null ) { itemId = IdGenerator ? . Invoke ( tableName ) ?? Guid . NewGuid ( ) . ToString ( " " ) ; instance = ( JObject ) instance . DeepClone ( ) ; instance [ SystemProperties . JsonIdProperty ] = itemId ; } var operation = new InsertOperation ( tableName , itemId ) ; await EnqueueOperationAsync ( operation , instance , cancellationToken ) . ConfigureAwait ( false ) ; }
Inserts an item into the offline table.
Inserts an item into the offline table .
// We have to pre-generate the ID when doing offline work.
A task that returns the inserted data when complete.
A task that returns the inserted data when complete .
tableName
string
The name of the offline table.
The name of the offline table .
instance
JObject
The instance to insert into the table.
The instance to insert into the table .
cancellationToken
CancellationToken
A  to observe.
A to observe .