Reputation: 290
So i have a WCF data service up and running with .Net 4.5, EF6 & WCF data services 5.6 and have the following in InitializeService
public static void InitializeService(DataServiceConfiguration config)
{
config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);
config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;
config.UseVerboseErrors = true;
}
I have a .Net mvc app which i've added a service reference too and everything appears to be working and accessible, however when i try and return a collection of complex types i get the following error:
Collection types are only supported in version 3.0 of the OData protocol and higher versions. They are not supported in version 1.0.
I've also noticed that my service.edmx has dataService v1:
<edmx:DataServices m:DataServiceVersion="1.0" m:MaxDataServiceVersion="3.0" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
I've tested the service url with the below sproc and parameters in Fiddler and i can see it's using serviceVersion 1.0 in the header however when i try and use a var for the parameters it throws the above exception.
string querystring = string.Format("GetSecurityIdByName?securityName='{0}'", maincompany.Name);
IEnumerable<get_security_id_by_name_Result> getsecurityid = context.Execute<get_security_id_by_name_Result>(new Uri(querystring, UriKind.Relative), "GET", false);
What am i missing? How can i force it / execute the sproc using v3?
TIA
Upvotes: 4
Views: 286
Reputation: 290
Ok, sending the correct version via SendingRequest2() fixed the issue, but feels hacky and not the "proper" solution. Perhaps it's still a known bug as per this post my a Microsoft employee from 2012!
context.SendingRequest2 += (sender, eventArgs) => {
eventArgs.RequestMessage.SetHeader("MinDataServiceVersion", "3.0;NetFx");
};
Upvotes: 2