private void SaveAtomically(TableAction[] actions) { if (actions.Count() > 100) { throw new InvalidOperationException("Cannot atomically execute more than 100 operations"); } var partitionKeys = actions.Select(op => op.PartitionKey).Distinct(); if (partitionKeys.Count() > 1) { throw new InvalidOperationException("Cannot atomically execute operations on different partitions"); } var groupedByEntity = actions.GroupBy(op => Tuple.Create(op.PartitionKey, op.RowKey)); if (groupedByEntity.Any(g => g.Count() > 1)) { throw new InvalidOperationException("Cannot atomically execute two operations on the same entity"); } var tables = actions.Select(op => op.TableName).Distinct(); if (tables.Count() > 1) { throw new InvalidOperationException("Cannot atomically execute operations on multiple tables"); } lock ( _tables ) { var resultingTables = _tables.DeepCopy(); foreach (var action in actions) { action.Action(resultingTables); } _tables = resultingTables; } }
public InMemoryTableStorageProvider( MemoryStorageAccount account = null ) : base(new MemoryTableContext( account )) { }
public InMemoryTableStorageProvider(MemoryStorageAccount account = null) : base(new MemoryTableContext(account)) { }
public MemoryTableContext(MemoryStorageAccount account = null) { _tables = account ?? _sharedTables; }