views:

19

answers:

1

The following code always throws exception

....
DataServiceContext ctx = account.CreateCloudTableClient().GetDataServiceContext();
var val  = (from t in ctx.CreateTable<MyClass>("TableName") 
           select new {testval = t.id}).FirstOrDefault();

If I read the entity it works fine:

var val  = (from t in ctx.CreateTable<MyClass>("TableName") 
           select t).FirstOrDefault();

Is it impossible to read just one field (or a few, I don't want to read entity) from Azure table?

Thanks in advance.


Update:

Exception data: System.Data.Services.Client.DataServiceQueryException.

Message - "An error occurred while processing this request."

Internal Exception - code :"InvalidInput", message : "One of the request inputs is not valid."

+2  A: 

I seem to remember that the current implementation only supports getting the full entities and does not support anonymous classes.

Another option would be to fetch the complete entity and then transform it into an anonymous type. Do note that in this case you are actually pulling full entities and then transforming them, resulting in more bandwidth consumption than would actually be needed.

maartenba
Yeah, I finally ended up with pulling full entities and getting desired fields. I thought maybe I missed something obvious. Thanks.
a1ex07