Azure表存储查询指定长度的行键

Azure表存储查询指定长度的行键,azure,key,row,storage,Azure,Key,Row,Storage,我正在使用Azure存储表,我有如下条目: PK RK TypeOfSerializedObject foo_0 bar_0 type1 foo_0 bar_0_var_1 type2 IQueryable<type1> type1ent = from t in context.CreateQuery<type1>(tableName)

我正在使用Azure存储表,我有如下条目:

PK      RK            TypeOfSerializedObject
foo_0   bar_0         type1
foo_0   bar_0_var_1   type2
            IQueryable<type1> type1ent = from t in context.CreateQuery<type1>(tableName)
                                         where t.PartitionKey == String.Format("foo_{0:0}", arg1)
                                         && t.RowKey.CompareTo("bar_0") >= 0
                                         && t.RowKey.CompareTo("bar_9") <= 0
                                         select t;
是否有任何解决方案可以检索第一行(bar_0)而不检索另一行(bar_0_var_1)? (在我的例子中,这两行存储不同类型的序列化对象,我无法同时检索这两行)

我正在尝试这样做:

PK      RK            TypeOfSerializedObject
foo_0   bar_0         type1
foo_0   bar_0_var_1   type2
            IQueryable<type1> type1ent = from t in context.CreateQuery<type1>(tableName)
                                         where t.PartitionKey == String.Format("foo_{0:0}", arg1)
                                         && t.RowKey.CompareTo("bar_0") >= 0
                                         && t.RowKey.CompareTo("bar_9") <= 0
                                         select t;
我已经这样做了(效率不高)但我仍在寻找性能更好的解决方案

            IQueryable<string> type1ent = from t in context.CreateQuery<type1>(tableName)
                                                            where t.PartitionKey == String.Format("foo_{0:0}", arg1)
                                                            && t.RowKey.CompareTo("bar_0") > 0
                                                            && t.RowKey.CompareTo("bar_:") < 0
                                                            select new String(t.RowKey.ToArray());

             foreach(string rowKey in type1ent)
                if (rowKey.Length == "bar_0".Length)
                {
                    type1Entity = (from t in context.CreateQuery<type1>(tableName)
                                   where t.PartitionKey == String.Format("foo_{0:0}", arg1)
                                   && t.RowKey.CompareTo(rowKey) == 0
                                   select t).FirstOrDefault();

                    TYPE type = // deserialization of type1Entity.SerializedObject
                }
IQueryable type1ent=来自context.CreateQuery(tableName)中的t
其中t.PartitionKey==String.Format(“foo_{0:0}”,arg1)
&&t.RowKey.CompareTo(“bar_0”)>0
&&t.RowKey.CompareTo(“bar:”)<0
选择新字符串(t.RowKey.ToArray());
foreach(类型为1ent的字符串行键)
if(rowKey.Length==“bar_0.Length)
{
type1Entity=(来自context.CreateQuery(tableName)中的t)
其中t.PartitionKey==String.Format(“foo_{0:0}”,arg1)
&&t.RowKey.CompareTo(RowKey)==0
选择t).FirstOrDefault();
TYPE TYPE=//type1Entity.SerializedObject的反序列化
}

您获取数据的第一次查询非常好。我不清楚你为什么要第二次提取相同的数据。我在存储器中有两种类型的数据:foo_0 bar_0是“type1”类型foo_0 bar_0_var_1是“type2”类型(我将编辑第一篇文章以澄清这一点)。因此,我无法在第一次查询中检索这两个条目。所以我决定只从第一个查询中检索rowKeys,检查它的长度是否正确,如果正确,则再次从查询中获得正确的类型。