Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure table returns null value randomly

I have the next snippet of code in C#:

        var results = from g in this.context.MyStorageEventTable
                      where g.PartitionKey == partitionKey
                            && g.EventType == "MyEvent"
                      select g;
        var ev = results.FirstOrDefault();

which makes a consult to an Azure Table. This table contains more than 20000 entities. The problem is that sometimes the variable ev has a null value, and sometimes has the entity object. This occurs randomly. I know that the object exists in the table, so the null value is the wrong behavior. Why is this happening? Thank you!

like image 981
user1863854 Avatar asked Mar 07 '26 22:03

user1863854


1 Answers

Try results.AsTableServiceQuery().FirstOrDefault(). If that works, the problem was that a continuation token was coming back with the query, indicating there's more data, but you weren't issuing a followup query to follow that continuation token and get the rest of the data. You should just always use AsTableServiceQuery() to get continuation-token following for free.

like image 100
user94559 Avatar answered Mar 10 '26 11:03

user94559



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!