WCF Data Services
Speaking at the June STL .NET User Group
Jun 17th
This month I will be presenting "OData – Make a Feed for That" at the St. Louis .NET User Group.
From the website:
You might have heard of ADO.NET Data Services and are wondering why it’s now WCF Data Services (Or maybe you haven’t heard of either which is another reason to attend this month’s user group!). In this session we’ll explore the OData protocol that drives WCF Data Services and look at example OData services and how you can consume them easily in .NET and Silverlight. Join us and learn how OData can make the web your data source with this new standard.
As always, there is *free food* so you can come chew on that and tune out the speaker if that’s how you roll!
Chris is a human. From planet earth. He likes to watch his kids grow and his disposable income shrink. For 40 hours a week he is a consultant with Daugherty Business Solutions in the Custom Line of Service working on .NET projects. The rest of the time Chris is chasing his kids, spending time with his wife or playing Xbox (or all of the above at the same time). He also likes to speak at local user group meetings and conferences about Microsoft technologies. He is a 2009 Microsoft MVP and does not look at all like a clown.
Monday, June 28, 2010
5:30 – 6:00 pm Food and social
6:00 – 7:30 pm Program
Location:
Three City Place Drive
Suite 1100
Creve Coeur, MO 63141
Pretty URIs in WCF Data Services – Lose the .svc File
Apr 6th
I’m still testing this, but, it looks like in .NET 4 you will be able to use the new URL Routing to lose the .svc file in your WCF Data Services.
Step-by-step
Follow the standard steps for creating a WCF Data Service.
- Create a new, “Empty ASP.NET Web Application”
- Add an Entity Data Model
Once you have your entity data model, add a new class, derive it from DataService<T> where T is the entity set you created in the previous steps:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Data.Services; using System.Data.Services.Common; namespace ODataSample { public class ProductService : DataService<AdventureWorksLT2008Entities> { public static void InitializeService(DataServiceConfiguration config) { config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2; config.SetEntitySetAccessRule("Products", EntitySetRights.AllRead); config.SetEntitySetPageSize("Products", 20); } } }
Add a Global Application Class (global.asax). In the Application_Start method add the following snippet:
RouteTable.Routes.Add(new ServiceRoute("ProductCatalog", new WebServiceHostFactory(), typeof(ProductService)));
If all is well you should be able to hit F5 to debug. Since there is not a default page you’ll have to add the route name you specified onto the end of the URI. If all goes well you should see:
In my testing thus far it appears everything works as you’d expect in terms of appending on query parameters, etc.
