0

I have Azure table entity where I have queryResult with Partition Key, RowKey, Etag and Properties. I am trying to read Properties contains my table columns. But I am facing issue in reading the Properties using LINQ or tried to loop Properties and again I have to loop Properties as its contains My table columns... referred some samples which are telling to use table.ExecuteQuery(query);

But I am getting response contains 4 values and Properties contains my actual columns data.... any help really appreciated.

        Public class MyEntityModel : TableEntity
        {
             MyEntityModel (){}
                MyEnityModel(string Category, string Id){
                    PartitionKey=Category;
                    RowKey= Id;
              }

              Public string leaveCount{ get;set;}
              Public string leaveReason{get;set;}
         }

    TableQuery<DynamicTableEntity> query=new 
    TableQuery<DynamicTableEntity>();
     Var result = table.ExecuteQuerySegmented(query,token)
    Var entityItems=result.Results;
    Var propsItems=entityItems.Select(x=>x Properties). ToList();

Even if I am providing my entity model to query like

    TableQuery <MyEntityModel> query = new TableQuery();

I am getting data with Partition key and RowKey value, but Properties (entity column values) is null.

Mahee19
  • 21
  • 4

3 Answers3

0

We can use EntityPropertConverter to get the Properties details like below

var myAzureColumnData = EntityPropertyConverter.ConvertBack<MyEntityModel>(Properties,  new OperationContext());

This give me the column values.

We can also do like this

 Var result = table.ExecuteQuery(new TableQuery<MyEntityModel>());

This will create a object with the values....

Mahee19
  • 21
  • 4
0
using System;
using System.Collections.Generic;
using Azure.Data.Tables;
using System.Linq;  
using Azure;
     
public async Task<IEnumerable<T>> ListAsync(String? filter = null)
            {
                var table = new TableClient(_tableEndpointUri);
                var result = new List<T>();
                AsyncPageable<T> queryResultsMaxPerPage = table.QueryAsync<T>(filter: filter, maxPerPage: 100);
                
                await foreach (Page<T> page in queryResultsMaxPerPage.AsPages())
                {
                    result.AddRange(page.Values);
                }
    
                return result.AsEnumerable();
            }
Prateek Mishra
  • 1,226
  • 10
  • 21
0

In WATS DynamicTableEntity is a TableEntity with an internal properties bag so by all means you are getting the correct response. If you want to "unwrap them" then query against MyEntityModel not DynamicTableEntity.

I had to decompile the source when I migrated off of WATS to Azure.Data.Tables, happy coding. enter image description here

jjhayter
  • 352
  • 4
  • 19