【发布时间】:2019-06-13 06:53:29
【问题描述】:
我将 guid 存储在我的 azure 表存储中,但类型是 在 Azure 表存储门户中显示为字符串而不是 guid。
我正在使用带有 sas 令牌的 rest api 将实体存储在 azure table storage 中。
{
public Guid id {get;set;}
public string name {get;set;}
}
string sastoke = GetSasToken(); // no issues here
string url = config.table_storage_url + sastoken // no issues here
// assuming i already have rowkey and partition key
myClass entity = new myClass{id = Guid.NewGuid();name = "abcdef";}
var content = new StringContent(JsonConvert.SerializeObject(entity), Encoding.UTF8, "application/json");
// creating http client
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new
MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response = await client.PostAsync(url, content);
return response;
}
预期:id 的类型应该是 azure 表存储门户中的 guid。
实际:id 类型在 azure 表存储门户中显示字符串。
【问题讨论】:
-
您没有为 Guid 指定 OData 类型。见here
-
嗨@John,你能在上面的代码中举个例子吗?
标签: c# azure azure-table-storage