WCF Data Services
If you are following through the example on creating custom data service providers as on this blog:
http://blogs.msdn.com/b/alexj/archive/2010/01/08/creating-a-data-service-provider-part-3-metadata.aspx
And you notice that your entities are not showing up in the $metadata file, double check that you have added this:
public class service : MyNewDataService { // This method is called only once to initialize service-wide policies. public static void InitializeService(DataServiceConfiguration config) { config.SetEntitySetAccessRule("*", EntitySetRights.AllRead); config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2; } } Just remember to set the entity set access rules for all entities - other they won't show up!
Read more
Today I start a new project - the Composite Data Service Framework. The Composite Data Service Framework is a project that aims to obviate some of the limitations of WCF Data Services, specifically:
Allowing multiple data services to be aggregated in a single data service. Providing more support for Service Operations (such as auto-generation of proxies client-side). Aggregating different service types (entity framework, CLR types etc) Complementing OData services with traditional WCF services with a single definition of proxies client-side.
Read more
If you are struggling to fetch data from a Sharepoint OData service and getting an error as below:
[DataServiceClientException: Unauthorized] System.Data.Services.Client.QueryResult.Execute() +436914 System.Data.Services.Client.DataServiceRequest.Execute(DataServiceContext context, QueryComponents queryComponents) +133 Then ensure you are setting the Credentials property of your Data Service Context, as below:
// Create the data context. SharepointDataContext dc = new SharepointDataContext(new Uri("http://dksp/_vti_bin/listdata.svc")); // Provide default credentials, without this authorisation will fail! dc.Credentials = System.Net.CredentialCache.DefaultCredentials;
// Etc… var accounts = from a in dc.
Read more
Well this little issue took me a while to investigate, but the skinny is this:
If you are going to add a service reference to a Sharepoint OData service (e.g. http://sharepoint/_vti_bin/listdata.svc) then make sure your Sharepoint site name does NOT begin with a number - otherwise Visual Studio will fail to add the reference.
Quick and easy, but this took quite a while for me to find, hope it helps anyone in the same situation!
Read more