WCF Data Service Running sproc using the wrong version of the OData protocol

So, I have a WCF data service that works with .Net 4.5, EF6 and WCF 5.6 data services and having 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 application that also added a service link, and everything works and is available, however, when I try to 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 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 tested the service url with the sproc value below and the parameters in Fiddler, and I see it with serviceVersion 1.0 in the header, however, when I try to use var for the parameters that 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 sproc using v3?

TIA

+4
1

, SendingRequest2(), , , "" . , Microsoft 2012 !

https://social.msdn.microsoft.com/Forums/en-US/3a735526-59a9-494d-9240-7107e1ccceae/return-iqueryable-of-dtos-from-serviceoperation?forum=adodotnetdataservices

context.SendingRequest2 += (sender, eventArgs) => {
    eventArgs.RequestMessage.SetHeader("MinDataServiceVersion", "3.0;NetFx");
};
+1

Source: https://habr.com/ru/post/1612145/


All Articles