0

I am creating an API wrapper for my azure cosmos db table and it is not returning the row keys

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;

i don't know why it was just returning a blank value.

this is my entity Model

 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; }

    }

this is the result from postman:

{
        "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'\""
    }
Chris Anderson
  • 8,305
  • 2
  • 29
  • 37
Page F.P.T
  • 653
  • 4
  • 11
  • 24
  • okay i tried putting in a value in rowkey, and it is now returning a value but why is it not returning the default GUID that it is setting when we add an entity? sorry this is my first time using this. – Page F.P.T Sep 25 '18 at 11:01
  • you mean the retrieve value of rowkey dismatches the value you added before? – Jay Gong Sep 28 '18 at 08:55
  • Hi @JayGong, no i meant the default rowkey that it is returning. for example I input an entity without a partition key and without a rowkey it automatically saves that entity with an auto created guid but when i extract it using my wrapper api. it returns a blank rowkey value. – Page F.P.T Sep 28 '18 at 14:43
  • do you see that RowKey in cosmos explorer in doc you've created? what type is your RowKey prop? – Olha Shumeliuk Sep 30 '18 at 18:52
  • Hi @OlgaShumeliuk, yes it's there. the type is string. I have resorted in inputting a rowkey value for now but i really need it to be a guid which makes the generated rowkey great but its not returning a value :( – Page F.P.T Sep 30 '18 at 18:55

0 Answers0