Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Supported Linq for WCF Data Services

I'm looking for the full list of supported linq extension methods that are compatible with WCF Data Services.

By trial and error I've found First( Func ) and Single( Func ) aren't supported, any others?

This gives me a pretty good idea of whats supported, I just don't know whats actually translated via the IQueryProvider.

like image 989
John Farrell Avatar asked May 05 '10 17:05

John Farrell


2 Answers

I've found a site listing the unsupported linq methods

http://msdn.microsoft.com/en-us/library/ee622463.aspx#unsupportedMethods

like image 50
Mark Adamson Avatar answered Nov 15 '22 09:11

Mark Adamson


First and Single are not supported for Silverlight because Silverlight requires all networking be done async, but you can simulate it with code like this

NorthwindEntities context = new NorthwindEntities(new Uri("Northwind.svc", UriKind.Relative));
DataServiceQuery<Order> q = (DataServiceQuery<Order>)context.Orders.Take(1);
q.BeginExecute((IAsyncResult ar) =>
    {
        var o = ((DataServiceQuery<Order>)q).EndExecute(ar).First();
        txtOutput.Text = o.OrderID.ToString();
    }, null);

In this code you are requesting only one be sent over the network with the Take(1), and then once it is already on the client using First() or Single() to easily get the singleton reference.

There is no definitive list of supported Linq operators available that I know of.

-jeff

like image 39
Jeff Reed - MSFT Avatar answered Nov 15 '22 08:11

Jeff Reed - MSFT