CloudTableClient “The method 'FirstOrDefault' is not supported.”

Damir Dobric Posts

Next talks:



Follow me on Twitter: #ddobric




When working with CloudTableClient you might get following exception:


“The method 'FirstOrDefault' is not supported.”

This exception is caused for example by following example:

SyncTableEntity item = ctx.TFiles.FirstOrDefault(f => f.PartitionKey == m_Container && f.RowKey == “…”);

To workaround this you can use one of following two examples:    

SyncTableEntity item = (from f in ctx.TFiles where f.PartitionKey == m_Container && f.RowKey == m_BookmarkFileName select f).FirstOrDefault();

SyncTableEntity item = ctx.TFiles.Where(f => f.PartitionKey == m_Container && f.RowKey == m_BookmarkFileName).FirstOrDefault();

In fact the workaround is semantically the same as original example which fails. However, the crucial difference is in location where query is executed. In the first case the query should be executed by Table Service running in Windows Azure. Both workarounds however enforce execution of the query at the caller’s side. And this is supported.

Posted Mar 03 2011, 11:33 AM by Damir Dobric is a .Net Community Blog powered by daenet GmbH.