Dynamic linq queries and TableServiceContext? RRS feed

  • Question

  • hi


    Does anyone have any examples of using Dynamic linq queries with the tableServiceContext? Alternatively, does anyone have a sample with Expression trees?





    Thursday, December 2, 2010 8:12 PM


All replies

  • Hi,

    Here is resource on how to use expression tree


    and some one used the experssion to implement dynamic query


    However, there are limitation on OData query, some keywords such as 'in' is not supported. Avoid using them, then you could make dynamic query to the azure table.

    Friday, December 3, 2010 10:25 AM
  • Thanks Maud. 


    I had seen these links - or similar - before. However, my issue is specifically with tableServiceContext. I tried a while back to get it to work with the Dynamic extension with Azure's context and it just didn't work. Hence, I was looking for a specific example of someone having done it successfully. 


    As for expression trees, I'm looking at them now - but I NEED the IN clause functionality.  It can be simulated by a contains or (clearly) a long list of OR'd terms but this is very inefficient - at least from a coding perspective. 



    Friday, December 3, 2010 1:48 PM
  • You should remember that only a very limited amount of support for filters is provided in the underlying RESTful API. As regards the use of OR you should read the comments by Jai Haridas on this Azure Forum thread.
    Friday, December 3, 2010 7:04 PM
  • Ok so this is the issue:  how can I convert an IQueryable object to CloudTableQuery<t>? Is this expected to work, in the simple AND/OR cases?

       SynchronizationPartnershipCloudContext myDC = SynchronizationPartnershipCloudProvider.Instance.Context;

       IQueryable q = myDC.SynchronizationPartnerships.Where(queryExpression);

     ((CloudTableQuery<SynchronizationPartnership>) q).Execute();


    where syncpartnershipcloudContext is a descendant of TableServiceContext

    Note the where(queryExpression): this is using the DynamicLinq extensions and thus a) accepts a string and b) returns IQueryable. 

    Should I expect the Execute() on the typecasted query to work, assuming I keep my operators to the limitations of the REST API?

    If not, how to do?



    Friday, December 3, 2010 9:01 PM
  • You might want to look at:


    which converts an IQueryable to a CloudTableQuery.

    • Marked as answer by Mog Liang Friday, December 10, 2010 10:04 AM
    Friday, December 3, 2010 9:51 PM