Permalink
Browse files

added simple querying

  • Loading branch information...
1 parent d2bc8ea commit 8861f11d5f03add1d9faecf7d9350e139bc6f0aa @richorama committed Nov 7, 2013
@@ -171,6 +171,13 @@ private static string GetTableXml(Hashtable tableEntityProperties)
return result;
}
+ public string QueryTable(string tablename, string partitionKey, string rowKey)
+ {
+ var header = CreateAuthorizationHeader(null, ContentType, StringUtility.Format("/{0}/{1}(PartitionKey='{2}',RowKey='{3}')", AccountName, tablename, partitionKey, rowKey));
+ return SendWebRequest(StringUtility.Format("http://{0}.table.core.windows.net/{1}(PartitionKey='{2}',RowKey='{3}')", AccountName, tablename, partitionKey, rowKey), header, null, 0, "GET");
+
+ }
+
#region Request Handling
//DataServiceVersion: Set the value of this header to 1.0;NetFx.
@@ -200,9 +207,9 @@ private HttpWebRequest PrepareRequest(string url, string authHeader, byte[] file
return request;
}
- protected void SendWebRequest(string url, string authHeader, byte[] fileBytes = null, int contentLength = 0)
+ protected string SendWebRequest(string url, string authHeader, byte[] fileBytes = null, int contentLength = 0, string verb = "POST")
{
- HttpWebRequest request = PrepareRequest(url, authHeader, fileBytes, contentLength);
+ HttpWebRequest request = PrepareRequest(url, authHeader, fileBytes, contentLength, verb);
try
{
HttpWebResponse response;
@@ -215,7 +222,7 @@ protected void SendWebRequest(string url, string authHeader, byte[] fileBytes =
else
{
Debug.Print("Status was " + response.StatusCode);
- var ResponseBody = "";
+ var responseBody = "";
using (var responseStream = response.GetResponseStream())
using (var reader = new StreamReader(responseStream))
{
@@ -225,10 +232,11 @@ protected void SendWebRequest(string url, string authHeader, byte[] fileBytes =
{
reader.Read(bytes, 0, bytes.Length);
- ResponseBody = new string(bytes);
+ responseBody = new string(bytes);
}
}
- Debug.Print(ResponseBody);
+ Debug.Print(responseBody);
+ return responseBody;
}
//if (response.StatusCode == HttpStatusCode.Accepted)
//{
@@ -247,6 +255,7 @@ protected void SendWebRequest(string url, string authHeader, byte[] fileBytes =
Debug.Print("problem with signature!");
}
}
+ return null;
}
#endregion
@@ -1,6 +1,7 @@
using System;
using netmfazurestorage.Table;
using System.Collections;
+using Microsoft.SPOT;
namespace netmfazurestorage.Tests
{
@@ -19,6 +20,7 @@ public void Run()
this.TestInsert();
this.TestInsertDouble();
this.TestInsertExperimental();
+ this.QuerySingleEntity();
}
private void TestCreate()
@@ -78,12 +80,19 @@ public void TestInsertExperimental()
values.Add("guidfield", Guid.NewGuid());
values.Add("int32field", 32);
values.Add("stringfield", "string");
- //values.Add("datetimefield", DateTime.Now);
+ //values.Add("datetimefield", DateTime.Now); // not sure why this is appearing as a null in the table
values.Add("doublefield", (double)123.22);
values.Add("int64field", (Int64)64);
values.Add("boolfield", true);
this.client.InsertTableEntity_Experimental("netmftest", "2", Guid.NewGuid().ToString(), DateTime.Now, values);
}
+ public void QuerySingleEntity()
+ {
+ var output = this.client.QueryTable("netmftest", "2", "796440bd-95f6-0626-975b-764e6902844d");
+ Debug.Assert(null != output);
+ }
+
}
+
}
Binary file not shown.

0 comments on commit 8861f11

Please sign in to comment.