c# - How to query all rows in windows azure table storage? -
i trying list of entities inside azure table.
any idea how go writing query?
i using c# btw. thanks.
to answer question, following:
var acc = new cloudstorageaccount( new storagecredentials("account name", "account key"), false); var tableclient = acc.createcloudtableclient(); var table = tableclient.gettablereference("table name"); var entities = table.executequery(new tablequery<myentity>()).tolist();
however please keep in mind table service returns maximum of 1000 entities in single call it. if there're more 1000 entities available in table, returns continuation token
can used fetch next set of entities. executequery
method handles continuation token internally if want cancel operation reason, can't that.
a better approach use executequerysegmented
method , have application deal token. here's sample code so:
var acc = new cloudstorageaccount( new storagecredentials("account name", "account key"), false); var tableclient = acc.createcloudtableclient(); var table = tableclient.gettablereference("table name"); tablecontinuationtoken token = null; var entities = new list<myentity>(); { var queryresult = table.executequerysegmented(new tablequery<myentity>(), token); entities.addrange(queryresult.results); token = queryresult.continuationtoken; } while (token != null);
Comments
Post a Comment