Select in WCF data serviceis not supported

I was working on a WCF data service and wanted to group certain set of data. For this instance lets consider using the Northwind data service hosted here.  So my  code looked something  like this.

var prodGroups = from prod in NorthwindRepository.NorthwindAccess.Alphabetical_list_of_products
                                 select prodGroup;

Surprise surprise it doesnt work. At first I thought I did something wrong. Then I had a referenced the Northwind database installed in my system using the same code work as shown above. It worked. I surfed for the answer a bit and this is what I concluded.

When we add a service , in particular a WCF Data service, the context formed is a DataServiceContext type. Now every entity within the feed is shown as a property of the class which in turn encapsulates the data  returned by the service is wrapped as a  DataServiceQuery.   Now since DataServiceQuery class implements the IQueryable interface defined by LINQ,  intellisense in Visual Studio gives us the impression that any kind of query is composable. But the URI syntax has very limited query options as compared to LINQ. So every time you try something that is not expressible as a URI a NotSupportedException is thrown. This begs the question. What else is not supported ? Here’s a list of Unsupported LINQ Methods


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s