public async Task When_writing_to_existing_stream_null_stream_properties() { var properties = new { Property1 = "Foo", Property2 = 42 }; var stream = new Stream(partition, StreamProperties.From(properties)); var result = await Stream.WriteAsync(stream, CreateEvent("e1"), CreateEvent("e2")); stream = result.Stream; AssertNewStream(result, 2, properties); AssertStreamEntity(2, properties); var restored = Stream.From(partition, stream.ETag, stream.Version, properties: null); result = await Stream.WriteAsync(restored, CreateEvent("e3")); AssertNewStream(result, 3, new {}); AssertStreamEntity(3, properties); }
/// <summary> /// This the simplest approach. You just need to create an additional stream metadata column and then you can simply query on it. /// /// It's also the slowest approach of all, since all rows in a partition need to scanned. Still, it should /// perform quite well for majority of apps as there won't be too many rows in a single physical partition. /// </summary> async Task MultipleStreamsPerPartitionUsingStreamProperties() { var properties = StreamProperties.From(new { RowType = "STREAM" }); await Stream.ProvisionAsync(VirtualPartition("11"), properties); await Stream.ProvisionAsync(VirtualPartition("22"), properties); // the below code will scan all rows in a single physical partition // also, if there more than 1000 streams (header rows), pagination need to be utilized as per regular ATS limits var filter = TableQuery.CombineFilters( TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, Partition.PartitionKey), TableOperators.And, TableQuery.GenerateFilterCondition(nameof(StreamHeaderEntity.RowType), QueryComparisons.Equal, "STREAM") ); var count = Partition.Table .ExecuteQuery <StreamHeaderEntity>(filter) .Count(); Console.WriteLine(count); }