@@ -55,7 +55,7 @@ var product = new Product("catId-asdf", "1234")
5555await repo .PutAsync (product );
5656
5757// Enumerate all products in category "catId-asdf"
58- await foreach (var p in repo .EnumerateAsync (" catId-asdf" )
58+ await foreach (var p in repo .EnumerateAsync (" catId-asdf" ))
5959 Console .WriteLine (p .Price );
6060
6161// Get previously saved product.
@@ -76,8 +76,8 @@ example. In such a case, instead of a `TableRepository`, you can use a `TablePar
7676class Region
7777{
7878 public Region (string code , string name )
79- => (Id , Amount )
80- = (id , amount );
79+ => (Code , Name )
80+ = (code , name );
8181
8282 public string Code { get ; }
8383
@@ -87,20 +87,25 @@ class Region
8787
8888``` csharp
8989var account = CloudStorageAccount .DevelopmentStorageAccount ; // or production one
90- // tableName will default to "Entity" and partition key to "Order", but they can
90+ // We lay out the parameter names for clarity only.
9191// also be provided to the factory method to override the default behavior.
92- var repo = TablePartition .Create <Region >(storageAccount , region => region .Code );
92+ var repo = TablePartition .Create <Region >(storageAccount ,
93+ // tableName defaults to "Entity" if not provided
94+ tableName : " Reference" ,
95+ // partitionKey would default to "Region" too if not provided
96+ partitionKey : " Region" ,
97+ rowKey : region => region .Code );
9398
9499var region = new Region (" uk" , " United Kingdom" );
95100
96101// Insert or Update behavior (aka "upsert")
97102await repo .PutAsync (region );
98103
99104// Enumerate all regions within the partition
100- await foreach (var r in repo .EnumerateAsync ()
105+ await foreach (var r in repo .EnumerateAsync ())
101106 Console .WriteLine (r .Name );
102107
103- // Get previously saved order .
108+ // Get previously saved region .
104109Region saved = await repo .GetAsync (" uk" );
105110
106111// Delete region
@@ -110,7 +115,7 @@ await repo.DeleteAsync("uk");
110115await repo .DeleteAsync (saved );
111116```
112117
113- This is quite convenient for handing reference data , for example . Enumerating all entries
118+ This is quite convenient for handling reference data, for example. Enumerating all entries
114119in the partition wouldn't be something you'd typically do for your "real" data, but for
115120reference data, it could be useful.
116121
@@ -126,6 +131,30 @@ entity type to modify the default values used:
126131Values passed to the ` TableRepository.Create<T> ` or ` TablePartition.Create<T> ` override
127132declarative attributes.
128133
134+ ### TableEntity Support
135+
136+ Since these repository APIs are quite a bit more intuitive than working against a direct
137+ ` TableClient ` , you might want to retrieve/enumerate entities just by their built-in ` ITableEntity `
138+ properties, like ` PartitionKey ` , ` RowKey ` , ` Timestamp ` and ` ETag ` . For this scenario, we
139+ also support creating ` ITableRepository<TableEntity> ` and ` ITablePartition<TableEntity> `
140+ by using the factory methods ` TableRepository.Create(...) ` and ` TablePartition.Create(...) `
141+ without a (generic) entity type argument.
142+
143+ For example, given you know all ` Region ` entities saved in the example above, use the region ` Code `
144+ as the ` RowKey ` , you could simply enumerate all regions without using the ` Region ` type at all:
145+
146+ ``` csharp
147+ var account = CloudStorageAccount .DevelopmentStorageAccount ; // or production one
148+ var repo = TablePartition .Create (storageAccount ,
149+ tableName : " Reference" ,
150+ partitionKey : " Region" );
151+
152+ // Enumerate all regions within the partition as plain TableEntities
153+ await foreach (TableEntity region in repo .EnumerateAsync ())
154+ Console .WriteLine (region .RowKey );
155+ ```
156+
157+
129158## Installation
130159
131160```
0 commit comments