OData Connected Service 0.10.0 Release

Avatar

Clément

OData Connected Service 0.10.0 has been released and is available in the Visual Studio Marketplace. This release includes the following features and fixes:

  • Support for open types
  • Fix issue causing an error when reading the Csdl.xml model file when you have generated multiple services in your project
  • Minor bug fixes

1. Support for Open Types

Open Types are entity or complex types in OData which have dynamic properties (i.e. properties not declared in the schema). Previously, OData Connected Service did not provide support for dynamic properties in open types. Starting with this version, if a type is marked as open in the service model, OData Connected Service will generate a dictionary called DynamicProperties as a property of that type. The Microsoft.OData.Client.ContainerPropertyAttribute will be applied to that property to inform the OData client library that this dictionary contains dynamic properties. Without this attribute, the dynamic properties would be ignored by the client library.

A screenshot of a social media post Description automatically generated

You can add dynamic properties to instances of the type by adding key-value pairs to the dictionary, where the key is the name of the property:

var address = new Address();
address.DynamicProperties.Add("Foo", "Bar");
address.DynamicProperties.Add("Fizz", "Buzz");

To support this feature, we also needed to add support for open types in the OData client library (Micrsosoft.OData.Client NuGet package). However, at the time of this writing, the version of the client library that contains this feature has not yet been released. If you need this feature before that version is released, consider using the Nightly build.

If your project has a version of Microsoft.OData.Client that does not support dynamic properties, OData Connected Service will still generate the DynamicProperties dictionary, but will not add the ContainerProperty attribute. Therefore, the client will simply ignore the dynamic properties you add to the dictionary. If you later update the client library to a version that supports dynamic properties, you will need to update the connected service for the attribute to be generated.

2. Issue reading metadata from Csdl.xml file when you have multiple services

In previous versions, OData Connected Service generated a Csdl.xml file to store the metadata of the service you generated client proxies for. In case you generated proxies for different services in the same project, you would get an exception when you run the project because it would not know which Csdl.xml to read.

We have corrected this by generating a unique file name for each service based on the pattern [ServiceName]Csdl.xml (e.g. ODataService1Csdl.xml, ODataService2Csdl.xml). If your project contains generated client that use the older Csdl.xml filename, you will need to update the connected services. You will also have to manually delete the older Csdl.xml files.

A screenshot of text Description automatically generated

3. Other bug fixes

  • There was a bug that caused schema types that you had excluded from code generation to be auto-selected when you exclude an operation import that uses those types as parameter or return types. This bug has been fixed, excluding an operation or schema type should not cause other types to be automatically included.
  • When you created a connected service from a local metadata file and exported T4 templates instead of the actual code, the file path in the MetadataDocumentUri configuration property was not properly escaped. This issue has been corrected.

Stay tuned for future releases.

 

1 comment

Comments are closed. Login to edit/delete your existing comments

  • Avatar
    Shimmy Weitzhandler

    This is awesome!
    I wish OData EDM would have let you expose the following things. The first three are really crucial to me. Ordered by my personal priority.

    1. Attributes
    2. Interface implementations
    3. Generic types
    4. XML documentation

    Posted GH issue here: https://bit.ly/2Y1FJyj