We're trying to get set up with Web API 2.2 and OData v4 for ASP.NET + Silverlight 5.
Initiall POC had a Unit Test project connecting using Simple.OData. This worked great. But we've been unable to set up an OData Client on Silverlight 5.
Using Client Code Generator v4 and keep getting error
The type or namespace name 'Client' does not exist in the namespace 'Microsoft.OData' (are you missing an assembly reference?) C:\Workspaces\GKS\Main\Source\Simutek.Gks\Source\Simutek.Gks.UI.SL.Common\GksODataClient.cs Simutek.Gks.UI.SL.Common
Packages:
<package id="Microsoft.OData.Client" version="6.12.0" targetFramework="sl50" />
<package id="Microsoft.OData.Core" version="6.12.0" targetFramework="sl50" />
<package id="Microsoft.OData.Edm" version="6.12.0" targetFramework="sl50" />
<package id="Microsoft.Spatial" version="6.12.0" targetFramework="sl50" />
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="sl50" />
References look good and we've also tried AssemblyBinding in app.config:
<dependentAssembly>
<assemblyIdentity name="Microsoft.OData.Edm" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.12.0.0" newVersion="6.12.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.OData.Core" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.12.0.0" newVersion="6.12.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Spatial" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.12.0.0" newVersion="6.12.0.0" />
</dependentAssembly>
Update: Indeed, while the Microsoft.OData.Client NuGet package installs on Silverlight it does in fact not specify SL5 in its targets. I now see that the package only targets
portable-net45+wp8+win8+wpa
So while I can get things going in a PCL project, I can't do so in one targeting Silverlight 5.
Is there a work around, anyone who have achieved this?
Silverlight does not support the code generated by Microsoft's OData v4 Client Code Generator visx (OData Client T4), but no one's forcing you to use generated code.
Simply use the lib of your choice to create a connection to the OData service and reuse your own types (business objects).