Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #8 from richorama/master

added table entity delete
  • Loading branch information...
commit 1f0cd9510e13a3dd0fcdaf618421cd011cdb2a6a 2 parents c8fcb72 + 15e39ad
@richorama richorama authored
View
8 README.md
@@ -48,5 +48,11 @@ var entity = client.QueryTable("helloworld", "PK", "RK");
Or you can pass in an OData query, and get an array of Hashtables back:
```cs
-var entities = client.QueryTable("netmftest", "PartitionKey eq '2'");
+var entities = client.QueryTable("helloworld", "PartitionKey eq 'PK'");
```
+
+Delete an entity:
+
+```cs
+client.DeleteTableEntity("helloworld", "PK", "RK");
+```
View
2  TestRunner/Program.cs
@@ -14,7 +14,7 @@ public class Program
public static void Main()
{
- NetworkInterface networkInterface = NetworkInterface.GetAllNetworkInterfaces()[0];
+ var networkInterface = NetworkInterface.GetAllNetworkInterfaces()[0];
if (!networkInterface.IsDhcpEnabled || !networkInterface.IsDynamicDnsEnabled)
{
View
13 TestRunner/Tests/TableTests.cs
@@ -19,7 +19,7 @@ public TableTests(string account, string key)
public void Run()
{
- AzureStorageHttpHelper.AttachFiddler = true;
+ AzureStorageHttpHelper.AttachFiddler = false;
this.TestCreate();
@@ -41,6 +41,7 @@ public void Run()
this.QuerySingleEntity();
this.QueryMultipleEntities();
this.UpdateTableEntity();
+ this.DeleteTableEntity();
}
private void TestCreate()
@@ -140,6 +141,16 @@ public void UpdateTableEntity()
var code2 = this.client.UpdateTableEntity("ranetmftest", "3", rowKey.ToString(), DateTime.Now, values);
}
+ private void DeleteTableEntity()
+ {
+ var rowKey = Guid.NewGuid();
+ var values = new Hashtable();
+ var code1 = this.client.InsertTableEntity("ranetmftest", "4", rowKey.ToString(), DateTime.Now, values);
+
+ var code2 = this.client.DeleteTableEntity("ranetmftest", "4", rowKey.ToString());
+ Debug.Assert(code2 == HttpStatusCode.NoContent);
+ }
+
}
}
View
14 netmfazurestorage/Table/TableClient.cs
@@ -100,6 +100,18 @@ public HttpStatusCode UpdateTableEntity(string tablename, string partitionKey, s
return AzureStorageHttpHelper.SendWebRequest(StringUtility.Format("{0}/{1}(PartitionKey='{2}',RowKey='{3}')", _account.UriEndpoints["Table"], tablename, partitionKey, rowKey), header, DateHeader, VersionHeader, payload, contentLength, "PUT", false, this.additionalHeaders).StatusCode;
}
+ public HttpStatusCode DeleteTableEntity(string tablename, string partitionKey, string rowKey)
+ {
+ var header = CreateAuthorizationHeader(null, StringUtility.Format("/{0}/{1}(PartitionKey='{2}',RowKey='{3}')", _account.AccountName, tablename, partitionKey, rowKey));
+ Hashtable headers = new Hashtable();
+ foreach (var key in this.additionalHeaders.Keys)
+ {
+ headers.Add(key, this.additionalHeaders[key]);
+ }
+ headers.Add("If-Match", "*");
+ return AzureStorageHttpHelper.SendWebRequest(StringUtility.Format("{0}/{1}(PartitionKey='{2}',RowKey='{3}')", _account.UriEndpoints["Table"], tablename, partitionKey, rowKey), header, DateHeader, VersionHeader, null, 0, "DELETE", false, headers).StatusCode;
+ }
+
private string FormatEntityXml(string tablename, string partitionKey, string rowKey, DateTime timeStamp, Hashtable tableEntityProperties)
{
var timestamp = timeStamp.ToString("yyyy-MM-ddTHH:mm:ss.0000000Z");
@@ -281,6 +293,8 @@ protected string CreateAuthorizationHeader(byte[] content, string canonicalResou
}
#endregion
+
+
}
View
BIN  netmfazurestorage/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
Binary file not shown
Please sign in to comment.
Something went wrong with that request. Please try again.