Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

added table entity delete #8

Merged
merged 2 commits into from

1 participant

Richard Astbury
Richard Astbury
Owner

No description provided.

Richard Astbury richorama merged commit 1f0cd95 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 21, 2013
  1. Richard Astbury

    added table entity delete

    richorama authored
Commits on Nov 22, 2013
  1. Richard Astbury

    updated readme

    richorama authored
This page is out of date. Refresh to see the latest.
8 README.md
View
@@ -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");
+```
2  TestRunner/Program.cs
View
@@ -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)
{
13 TestRunner/Tests/TableTests.cs
View
@@ -19,7 +19,7 @@ public TableTests(string account, string key)
public void Run()
{
- AzureStorageHttpHelper.AttachFiddler = true;
+ AzureStorageHttpHelper.AttachFiddler = false;
this.TestCreate();
this.TestInsert();
@@ -28,6 +28,7 @@ public void Run()
this.QuerySingleEntity();
this.QueryMultipleEntities();
this.UpdateTableEntity();
+ this.DeleteTableEntity();
}
private void TestCreate()
@@ -127,6 +128,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);
+ }
+
}
}
14 netmfazurestorage/Table/TableClient.cs
View
@@ -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
+
+
}
BIN  netmfazurestorage/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
View
Binary file not shown
Something went wrong with that request. Please try again.