private static void DeleteTable() { var systemL = AllPet.Pipeline.PipelineSystem.CreatePipelineSystemV1(new AllPet.Common.Logger()); systemL.OpenNetwork(new AllPet.peer.tcp.PeerOption()); var remote = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("127.0.0.1"), 8888); var systemref = systemL.ConnectAsync(remote).Result; systemL.Start(); var actor = systemL.GetPipeline(null, "127.0.0.1:8888/simpledb"); { DeleteTableCommand command = new DeleteTableCommand() { TableId = new byte[] { 0x02, 0x02, 0x03 } }; var bytes = ProtocolFormatter.Serialize <DeleteTableCommand>(Method.DeleteTable, command); actor.Tell(bytes); } systemL.CloseListen(); systemL.CloseNetwork(); systemL.Dispose(); }
public async Task Crud() { ICommand createCommand = new CreateTableEntitiesCommand(); ICommand readCommand = new ReadTableEntitiesCommand <TestTableEntity>(); ICommand updateCommand = new UpdateTableEntitiesCommand(); ICommand deleteCommand = new DeleteTableEntitiesCommand(); ICommand deleteTableCommand = new DeleteTableCommand(); var partitionKey = Guid.NewGuid().ToString(); const int count = 5; var entities = new List <TestTableEntity>(); for (var i = 0; i < count; i++) { entities.Add(new TestTableEntity { PartitionKey = partitionKey, RowKey = Guid.NewGuid().ToString(), Text = i.ToString() }); } var filter = TableQuery.GenerateFilterCondition(LvConstants.PartitionKey, QueryComparisons.Equal, partitionKey); // create dynamic c = await GetInitialExpandoObjectAsync(); c.Entities = entities; await createCommand.ExecuteAsync(c); // read dynamic r = await GetInitialExpandoObjectAsync(); r.Filter = filter; await readCommand.ExecuteAsync(r); List <TestTableEntity> entitiesR = r.Entities; Assert.True(entities.ToJsonString().CosineEqual(entitiesR.ToJsonString())); // update var entities2 = entities.CloneByJson(); var updatedText = Guid.NewGuid().ToString(); foreach (var entity in entities2) { entity.Text = updatedText; } dynamic u = await GetInitialExpandoObjectAsync(); u.Entities = entities2; await updateCommand.ExecuteAsync(u); dynamic r2 = await GetInitialExpandoObjectAsync(); r2.Filter = filter; await readCommand.ExecuteAsync(r2); List <TestTableEntity> entitiesR2 = r2.Entities; for (var i = 0; i < count; i++) { Assert.Equal(entities2[i].Text, entitiesR2[i].Text); } // delete dynamic d = await GetInitialExpandoObjectAsync(); d.Entities = entities2; await deleteCommand.ExecuteAsync(d); dynamic r3 = await GetInitialExpandoObjectAsync(); r3.Filter = filter; await readCommand.ExecuteAsync(r3); List <TestTableEntity> entitiesR3 = r3.Entities; Assert.Empty(entitiesR3); dynamic dt = await GetInitialExpandoObjectAsync(); await deleteTableCommand.ExecuteAsync(dt); }
public void Handle(DeleteTableCommand command) { Console.WriteLine("DeleteTableCommand"); this.SimpleDb.DeleteTableDirect(command.TableId); }
public async Task Crud() { ICommand createCommand = new CreateTableEntityCommand(); ICommand readCommand = new ReadTableEntityCommand <TestTableEntity>(); ICommand updateCommand = new UpdateTableEntityCommand(); ICommand deleteCommand = new DeleteTableEntityCommand(); ICommand deleteTableCommand = new DeleteTableCommand(); var partitionKey = Guid.NewGuid().ToString(); var rowKey = Guid.NewGuid().ToString(); var text = Guid.NewGuid().ToString(); var entity = new TestTableEntity { PartitionKey = partitionKey, RowKey = rowKey, Text = text }; // create dynamic c = await GetInitialExpandoObjectAsync(); c.Entity = entity; await createCommand.ExecuteAsync(c); // read dynamic r = await GetInitialExpandoObjectAsync(); r.PartitionKey = partitionKey; r.RowKey = rowKey; await readCommand.ExecuteAsync(r); TestTableEntity entityR = r.Entity; Assert.Equal(entity.PartitionKey, entityR.PartitionKey); Assert.Equal(entity.RowKey, entityR.RowKey); Assert.Equal(entity.Text, entityR.Text); // update var text2 = Guid.NewGuid().ToString(); var entity2 = entity.CloneByJson(); entity2.Text = text2; dynamic u = await GetInitialExpandoObjectAsync(); u.Entity = entity2; await updateCommand.ExecuteAsync(u); dynamic r2 = await GetInitialExpandoObjectAsync(); r2.PartitionKey = partitionKey; r2.RowKey = rowKey; await readCommand.ExecuteAsync(r); TestTableEntity entityR2 = r.Entity; Assert.Equal(entity2.PartitionKey, entityR2.PartitionKey); Assert.Equal(entity2.RowKey, entityR2.RowKey); Assert.Equal(entity2.Text, entityR2.Text); // delete dynamic d = await GetInitialExpandoObjectAsync(); d.Entity = entity2; await deleteCommand.ExecuteAsync(d); dynamic r3 = await GetInitialExpandoObjectAsync(); r3.PartitionKey = partitionKey; r3.RowKey = rowKey; await readCommand.ExecuteAsync(r); TestTableEntity entityR3 = r.Entity; Assert.Null(entityR3); dynamic dt = await GetInitialExpandoObjectAsync(); await deleteTableCommand.ExecuteAsync(dt); }