C#API服务未返回RowKey

时间:2018-09-25 09:39:05

标签: c# azure-cosmosdb azure-cosmosdb-tables

我正在为我的azure cosmos db表创建一个API包装器,并且它没有返回行键

List<NewQuestionsEntity> _records = new List<NewQuestionsEntity>();

            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(_connectionString);
            CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
            CloudTable table = tableClient.GetTableReference("QnA");
            table.CreateIfNotExists();

            TableQuery<NewQuestionsEntity> query = new TableQuery<NewQuestionsEntity>();

            foreach (NewQuestionsEntity entity in table.ExecuteQuery(query))
            {
                Console.WriteLine("{0}, {1}\t{2}\t{3}", entity.PartitionKey, entity.RowKey,
                    entity.PostedDate, entity.PostedBy);
                _records.Add(entity);
            }

            return _records;

我不知道为什么它只是返回一个空白值。

这是我的实体模型

 public class NewQuestionsEntity : TableEntity
    {
        public NewQuestionsEntity(string skey, string rkey)
        {
            this.PartitionKey = skey;
            this.RowKey = rkey;
        }

        public NewQuestionsEntity() { }

        public string PostedBy { get; set; }
        public DateTime PostedDate { get; set; }
        public string Contact { get; set; }
        public string Status { get; set; }
        public string Question { get; set; }

    }

这是邮递员的结果

{
        "PostedBy": "test",
        "PostedDate": "2018-09-09T09:00:00Z",
        "Contact": "test",
        "Status": "test",
        "Question": "test",
        "PartitionKey": "test",
        "RowKey": "",
        "Timestamp": "2018-09-25T10:04:58+00:00",
        "ETag": "W/\"datetime'2018-09-25T10%3A04%3A58.0139459Z'\""
    }

0 个答案:

没有答案