开发者

Can I query any attribute in a Windows Azure Tablestorage row?

开发者 https://www.devze.com 2023-03-03 14:39 出处:网络
Sorry if this sounds like a rather dumb question but I would like to do a \"select\" on data from a Windows Azure table. I tried the following and it worked:

Sorry if this sounds like a rather dumb question but I would like to do a "select" on data from a Windows Azure table. I tried the following and it worked:

from question in _statusTable.GetAll()
                       where 开发者_JAVA百科status.RowKey.StartsWith(name)

I then tried

from question in _statusTable.GetAll()
                       where status.Description.StartsWith(name)

This one gave me nothing. Can anyone explain to me if or how I can query on rows that are not part of the RowKey or PartitionKey.


You can query on any property, but the types of query supported are limited - e.g. StartsWith isn't supported. Also if you aren't querying on PartitionKey and RowKey, then there are some very important performance issues to understand - and you always need to be aware of ContinuationToken's - almost any query result can contain these.

You can see the sorts of queries supported by looking at the REST API: http://msdn.microsoft.com/en-us/library/dd894031.aspx - it's pretty limited (but quick as a result):

  • Equal
  • GreaterThan
  • GreaterThanOrEqual
  • LessThan
  • LessThanOrEqual
  • NotEqual

If you need to do more, then:

  • you can mimic things like StartsWith("Fred") by doing a GreaterThanOrEqualTo("Fred") and LessThan("Free")
  • or client side filtering will work - but that means pulling back all the rows from the storage - which could be a lot of data and which could be computationally and transactionally expensive!


What does GetAll() do? StartsWith isn't supported by WA tables, so I'm assuming GetAll pulls all the data local, and so your query is done over objects in memory. If so, this has nothing to do with Windows Azure, so I'd take a look at whether your data looks like you expect it to.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号