You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -117,7 +117,7 @@ If you used a previous version of this library, you may remember a more complica
117
117
118
118
Notice that we introduced a new class called ```PartitionKey```. This class is a simple DTO to capture ```CompanyId``` and ```DepartmentId```. A nice side effect of having a class for this is that we gain type safety and intellisense.
119
119
120
-
```csharp
120
+
```c#
121
121
publicclassPartitionKey
122
122
{
123
123
publicPartitionKey(intcompanyId, intdepartmentId)
@@ -131,7 +131,7 @@ public class PartitionKey
131
131
```
132
132
Inserting data is the same as always:
133
133
134
-
```csharp
134
+
```c#
135
135
varemployee=newEmployee
136
136
{
137
137
CompanyId=1,
@@ -144,7 +144,7 @@ tableStore.Insert(employee);
144
144
In table storage, the partition key for the above example would be "1.22" and its row key would be "1".
145
145
146
146
To retrieve the record, we can use ```PartitionKey``` to build the multi-part key.
147
-
```csharp
147
+
```c#
148
148
var record = tableStore.GetRecord(new PartitionKey(1, 22), 1);
149
149
```
150
150
@@ -155,15 +155,15 @@ Note that in v1.3 of the library we've simplified fixed key scenarios by introdu
155
155
156
156
Again, we will use a contrived example. Here we have use ```Id``` as partition key , and we always use the word "user" for rowkey, since this will not be used.
We can also get the record using the typed overload, though in this case the second parameter is thrown away since there is no row key. I prefer to use ```int.Min``` to show that this value is thrown away.
184
184
185
-
```csharp
185
+
```c#
186
186
record = tableStore.GetRecord(1, int.MinValue);
187
187
```
188
188
@@ -196,7 +196,7 @@ which is both clear and provides type safety.
196
196
Coupled with [TableStorage.Abstractions.POCO.SecondaryIndexes](https://github.com/giometrix/TableStorage.Abstractions.POCO/tree/master/src/TableStorage.Abstractions.POCO.SecondaryIndexes) , you can do things like saving a historical record when mutating your main table entity.
#### Custom Property Conversion For Non-Key Fields
261
+
Starting in v3.1 you can specify custom property converters for properties that are not used as Partition or Row Key fields.
262
+
263
+
This is a niche use case, but useful if you need it, for example, if dates are stored as strings in Azure Table Storage.
264
+
265
+
Here is the test object we'll be using in the example:
266
+
```c#
267
+
varemployee=newEmployeeWithHireDate
268
+
{
269
+
Name="Test",
270
+
CompanyId=99,
271
+
Id=99,
272
+
HireDate=newDateTime(1999,12,31),
273
+
Department=newDepartment {Id=5, Name="Test"}
274
+
};
275
+
```
276
+
First we need to specify property converters. PropertyConverters is a dictionary. The key is the property name and the value is a PropertyConverter, which specifies how to convert to and from EntityProperty.
0 commit comments