OData / ODataConnectedService

A Visual Studio extension for generating client code for OData Services
Other
79 stars 41 forks source link

Using Microsoft.OData.XX instaed of Microsoft.Data.XX #410

Open DomSchmHopp opened 3 weeks ago

DomSchmHopp commented 3 weeks ago

Hi ! I have to develop an application which uses an OData service from SAP (R3). But whenever I import the metadata file to the Odata Connected Service Importer I get proxy classes which use the deprecated Microsoft.Data.XX libraries (Version 5.8.5). The most of these libs are marked as deprecated.

Can anyone give me a hint how to change to the new Microsoft.OData.XX Libs (Version 8.0.1)?

This is the metadata.xml file I import:

<edmx:Edmx Version="1.0"
    xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx"
    xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
    xmlns:sap="http://www.sap.com/Protocols/SAPData">
    <edmx:DataServices m:DataServiceVersion="2.0">
        <Schema Namespace="ZPP_SERIALISIERUNG_ZW_SRV" xml:lang="en" sap:schema-version="1"
            xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
            <ComplexType Name="Component">
                <Property Name="ComponentNumber" Type="Edm.String" Nullable="false" MaxLength="18" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
                <Property Name="MaterialDescription" Type="Edm.String" MaxLength="40" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
                <Property Name="SerializationProfile" Type="Edm.String" MaxLength="4" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
                <Property Name="RequiredQuantity" Type="Edm.Decimal" Precision="13" Scale="3" sap:unit="RequiredQuantityUnit" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
                <Property Name="RequiredQuantityUnit" Type="Edm.String" MaxLength="3" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false" sap:semantics="unit-of-measure"/>
            </ComplexType>
            <ComplexType Name="Equipment">
                <Property Name="EquipmentNumber" Type="Edm.String" Nullable="false" MaxLength="18" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
            </ComplexType>
            <EntityContainer Name="ZPP_SERIALISIERUNG_ZW_SRV_Entities" m:IsDefaultEntityContainer="true" sap:supported-formats="atom json xlsx">
                <FunctionImport Name="getComponentsWithSerializationProfile" ReturnType="Collection(ZPP_SERIALISIERUNG_ZW_SRV.Component)" m:HttpMethod="GET">
                    <Parameter Name="ProductionOrderNumber" Type="Edm.String" Mode="In" MaxLength="12"/>
                </FunctionImport>
                <FunctionImport Name="serialize" ReturnType="ZPP_SERIALISIERUNG_ZW_SRV.Equipment" m:HttpMethod="POST">
                    <Parameter Name="MaterialNumbersComponents" Type="Edm.String" Mode="In"/>
                    <Parameter Name="SerialNumber" Type="Edm.String" Mode="In" MaxLength="18"/>
                    <Parameter Name="ProductionOrderNumber" Type="Edm.String" Mode="In" MaxLength="12"/>
                    <Parameter Name="MaterialNumber" Type="Edm.String" Mode="In" MaxLength="18"/>
                    <Parameter Name="SerialNumbersComponents" Type="Edm.String" Mode="In"/>
                </FunctionImport>
            </EntityContainer>
            <atom:link rel="self" href="http://URL:8000/sap/opu/odata/SAP/ZPP_SERIALISIERUNG_ZW_SRV/$metadata"
                xmlns:atom="http://www.w3.org/2005/Atom"/>
                <atom:link rel="latest-version" href="http://URL:8000/sap/opu/odata/SAP/ZPP_SERIALISIERUNG_ZW_SRV/$metadata"
                    xmlns:atom="http://www.w3.org/2005/Atom"/>
                </Schema>
            </edmx:DataServices>
        </edmx:Edmx>

Any hint would be much appreciated because I don´t want to implement a new tool with outdated libs.

Dominik

WanjohiSammy commented 2 weeks ago

@DomSchmHopp Are those old versions of OData working for you as expected.

Also note that the CSDL that you are using is V2 and only works with the packages Microsoft.Data.XX. To have latest packages, opt to use V3 or V4

habbes commented 1 week ago

@WanjohiSammy @DomSchmHopp V3 also only works with System.Data.XX, to use Microsoft.OData.XX, you should be using a CSDL version v4 (4.0 or 4.01).