Ejemplo n.º 1
0
        /// <summary>
        /// Begins the async save changes operation
        /// </summary>
        /// <returns></returns>
        public Task SaveChangesAsync()
        {
            return(asyncDocumentKeyGeneration.GenerateDocumentKeysForSaveChanges()
                   .ContinueWith(keysTask =>
            {
                keysTask.AssertNotFailed();

                var cachingScope = EntitiesToJsonCachingScope();
                try
                {
                    var data = PrepareForSaveChanges();
                    return AsyncDatabaseCommands.BatchAsync(data.Commands.ToArray())
                    .ContinueWith(task =>
                    {
                        try
                        {
                            UpdateBatchResults(task.Result, data);
                        }
                        finally
                        {
                            cachingScope.Dispose();
                        }
                    });
                }
                catch
                {
                    cachingScope.Dispose();
                    throw;
                }
            }).Unwrap());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Begins the async save changes operation
        /// </summary>
        /// <returns></returns>
        public Task SaveChangesAsync()
        {
            var data = PrepareForSaveChanges();

            return(AsyncDatabaseCommands.BatchAsync(data.Commands.ToArray())
                   .ContinueWith(task => UpdateBatchResults(task.Result, data.Entities)));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Begins the async save changes operation
        /// </summary>
        /// <returns></returns>
        public Task SaveChangesAsync()
        {
            var cachingScope = EntitiesToJsonCachingScope();
            var data         = PrepareForSaveChanges();

            return(AsyncDatabaseCommands.BatchAsync(data.Commands.ToArray())
                   .ContinueWith(task =>
            {
                UpdateBatchResults(task.Result, data.Entities);
                cachingScope.Dispose();
            }));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Begins the async save changes operation
        /// </summary>
        /// <returns></returns>
        public async Task SaveChangesAsync(CancellationToken token = default(CancellationToken))
        {
            await asyncDocumentKeyGeneration.GenerateDocumentKeysForSaveChanges().WithCancellation(token);

            using (EntityToJson.EntitiesToJsonCachingScope())
            {
                var data = PrepareForSaveChanges();
                if (data.Commands.Count == 0)
                {
                    return;
                }

                IncrementRequestCount();

                var result = await AsyncDatabaseCommands.BatchAsync(data.Commands.ToArray(), token);

                UpdateBatchResults(result, data);
            }
        }