查询空值蔚蓝的表存储 [英] Querying azure table storage for null values

查看:166
本文介绍了查询空值蔚蓝的表存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道查询蔚蓝的表存储空值的正确方法。从我读过的东西,这是可能的(虽然是prevents它发展的存储错误)。不过,我不断收到以下错误,当我在现场云存储这样做的:

Does anyone know the proper way to query azure table storage for a null value. From what I've read, it's possible (although there is a bug which prevents it on development storage). However, I keep getting the following error when I do so on the live cloud storage:

其中一个请求输入无效。

One of the request inputs is not valid.

这是我已经把LINQ查询的简单化版本。

This is a dumbed down version of the LINQ query that I've put together.

var query = from fooBar in fooBarSVC.CreateQuery<FooBar>("FooBars")
        where fooBar.PartitionKey == kPartitionID
            && fooBar.Code == kfooBarCode
            && fooBar.Effective_Date <= kFooBarDate.ToUniversalTime()
            && (fooBar.Termination_Date > kFooBarDate.ToUniversalTime() || fooBar.Termination_Date == null)
        select fooBar;

如果我运行查询,而不检查空,它工作正常。我知道一个可能的解决方案将是,以运行该查询带回集合的第二查询。我不介意做,如果我需要,但想知道如果我能得到这个办法先工作。

If I run the query without checking for null, it works fine. I know a possible solution would be to run a second query on the collection that this query brings back. I don't mind doing that if I need to, but would like to know if I can get this approach to work first.

任何人看到什么明显的,我做错了?

Anyone see anything obvious I'm doing wrong?

推荐答案

的问题是,由于蔚蓝的表存储没有一个模式,空列实际上并不存在。这就是为什么您的查询是无效的。还有如表存储空列这样的事情。你可以这样做店一个空字符串,如果你真的不得不这样做。真的不过根本问题这里要说的是Azure的表存储还真不是建比分区键和行键以外的任何栏目进行查询。您在这些不规范的其中一列的查询,每一次你在做一个表扫描。如果你开始得到大量的数据,您将有查询超时非常高的速度。我建议设立为这些类型的查询手动索引。例如,可以存储在同一表中,但与该行密钥不同的值相同的数据。最终,如果您正在应用程序是不是越来越疯狂使用率很高,我只想使用SQL Azure的,因为它会为你正在做的类型的查询更加灵活。

The problem is that because azure table storage does not have a schema, the null column actually doesn't exist. This is why your query is not valid. there is no such thing as a null column in table storage. You could do something like store an empty string if you really have to. Really though the fundamental issue here is that Azure table storage really is not built to be queried by any columns other than partition key and row key. Every time you make a query on one of these non-standard columns you are doing a table scan. If you start to get lots of data you are going to have a very high rate of query time outs. I would suggest setting up a manual index for these types of queries. For example, you could store the same data in the same table but with different values for the Row key. Ultimately, if your are app is not getting crazy high usage I would just use SQL Azure as it will be much more flexible for the types of queries you are doing.

更新:天青对表存储的设计,我会建议阅读的一个很好的指南。的http://azure.microsoft.com/en-us/documentation/articles/storage-table-design-guide/

Update: Azure has a great guide on table storage design that I would recommend reading. http://azure.microsoft.com/en-us/documentation/articles/storage-table-design-guide/

这篇关于查询空值蔚蓝的表存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆