...and everything in between RSS 2.0
# Thursday, April 07, 2011

Hit this little hurdle recently while creating WCF Data Service against Azure Table Storage. At the moment only a handful of operators are supported by the client library when using the Table Storage Service.

Supported Query Operators

LINQ operator

Table service support

Additional information

From

Supported as defined.

 

Where

Supported as defined.

 

Take

Supported, with some restrictions.

The value specified for the Take operator must be less than or equal to 1,000. If it is greater than 1,000, the service returns status code 400 (Bad Request).

If the Take operator is not specified, a maximum of 1,000 entries will be returned.

First, FirstOrDefault

Supported.

 

What this means is that we can not perform LINQ queries that group, order by, distinct or even return single entity properties from the query (we must always return the entire entity). In most situations the solution is to construct our LINQ queries that first make use of the supported operators and then use AsEnumerable() followed by any operations that are not supported. This generates two parts to the LINQ query. The first part (everything before the AsEnumerable) gets sent to the backend (Azure Table Storage in this case) and the remaining parts execute locally against the results of the first (in-memory). This helps get over the road-block but as you can image you are bringing a greater chunk of data down to the client and continuing processing there.

Some examples:

Using Distinct()

var query = myTableServiceContext.MyEntity.Where(e => e.Category == someCatgeory).AsEnumerable().Select(c => c.Name).Distinct();
 
Select next 5 entities after a given date and time (using OrderBy together with Take)
 
var query = myTableServiceContext.MyEntity.Where(e => e.Category == someCatgeory & e.StartDate > DateTime.UtcNow).AsEnumerable().OrderBy(o => o.StartDate).Take(5);

For further details check out the online documentation.

Thursday, April 07, 2011 8:32:00 PM (AUS Eastern Standard Time, UTC+10:00)  #    - Trackback
.NET Framework | WCF | Windows Azure
Navigation
Archive
<September 2014>
SunMonTueWedThuFriSat
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011
Blogroll
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2014
Breeze
Sign In
Statistics
Total Posts: 64
This Year: 0
This Month: 0
This Week: 0
Comments: 182
Themes
Pick a theme:
All Content © 2014, Breeze
DasBlog theme 'Business' created by Christoph De Baene (delarou)