Querying for existing record by rowkey and partitionkey returns empty

Answered Querying for existing record by rowkey and partitionkey returns empty

  • sábado, 04 de septiembre de 2010 14:39
     
     

    The following code return empty for a record that exists in the datastore. Can anyone help?

     

    public T Select(string partitionKey, string rowKey)

            {

                try

                {

                    System.Diagnostics.Trace.TraceInformation("Selecting {2} entry with row key {0} and partition key {1}", rowKey, partitionKey, typeof(T).Name);

                    IQueryable<T> results = Select(entry => entry.RowKey == rowKey && entry.PartitionKey == partitionKey);

                    if (results != null)

                    {

                        return results.FirstOrDefault<T>();

                    }

                }

                catch (Exception ex)

                {

                    System.Diagnostics.Trace.TraceInformation("Exception thrown while attempting to select record of type {2} with row key {3}: {0} {1}", ex.Message, ex.StackTrace, typeof(T).Name, rowKey);

                }

                return null;

            }

     public IQueryable<T> Select(Func<T, bool> condition)

            {

                try

                {

                    System.Diagnostics.Trace.TraceInformation("Selecting {0} entries with conditions", typeof(T).Name);

                    return this.context.Entries.Where(condition).AsQueryable<T>();

                }

                catch (Exception ex)

                {

                    System.Diagnostics.Trace.TraceInformation("Exception thrown while attempting to select record of type {2} : {0} {1}", ex.Message, ex.StackTrace, typeof(T).Name);

                }

                return null;

            }

Todas las respuestas

  • sábado, 04 de septiembre de 2010 17:46
    Usuario que responde
     
     

    I would use Fiddler to verify precisely what is going over the wire to Azure storage. Adam Sampson has a post describing a configuration change to use Fiddler with Development Storage.

  • sábado, 04 de septiembre de 2010 18:37
     
     
    Thank you for your reply. The problem is that it only happens on the production Azure account. On my development storage it works fine.
  • sábado, 04 de septiembre de 2010 19:21
     
     

    One more thing is worth noting: it happens when the number of records in the table gets to few hundreds or 1000. I am not sure what comes first or in which exact number.

    Does the partitioning key format may have an impact? the partition key format I use is:

    string.format("TIME_{0}", DateTime.UtcNow.ToString("MMyyyy"));

  • sábado, 04 de septiembre de 2010 21:49
     
     
    If you're running against cloud storage, you can use Fiddler straightforwardly without having to do what's in Adam's post.  It would help to see what's happening there... if you can paste the full query and response here, that will make it easier to figure out what's going on.
  • domingo, 05 de septiembre de 2010 6:35
     
     

    Hi Steve,

    It is hapening inside a worker role. Can I use fiddler with a worker role?

    The strange things is that the above code is used for all queries in the system and it works fine. Then, in some unpredictable situations, the same code returns empty results.

     

    Please help.

  • domingo, 05 de septiembre de 2010 6:36
     
     
    You can use it when you're running locally.
  • domingo, 05 de septiembre de 2010 7:41
    Usuario que responde
     
     Respondida

    You should try running the worker role in the Development Fabric pointing to Azure Storage and use Fiddler to trap the information sent over the wire. This allows you to see precisely what request is being made of the Storage Service and the response to that request. If there is no resource found with a specific PartitionKey and RowKey you should use some method outside your app to verify the existence of the entity actually queried. You could perhaps use Cloud Storage Studio or even a simple console app that just retrieves that record using different code from that used in the worker role.

  • martes, 07 de septiembre de 2010 19:37
     
     

    Can I pass a dynamic expression to a "where" function?

    public

     

     

     void Select(Func<T, bool> condition)

    {

     

     

     

    var query = (from t in this.context.Entries

     

     

    where condition.Invoke(t)

     

     

    select t) as DataServiceQuery<T>;

    }

    The above throws a run time exception. What am I missing?

  • jueves, 09 de septiembre de 2010 2:32