What's New in ASP.NET Web API OData 5.3

by Microsoft

This topic describes what's new for ASP.NET Web API OData 5.3.

Download

The runtime features are released as NuGet packages on the NuGet gallery. You can install or update to the released NuGet packages by using the NuGet Package Manager Console:

Install-Package Microsoft.AspNet.OData -Version 5.3.0 
Install-Package Microsoft.AspNet.WebApi.OData -Version 5.3.0

Documentation

You can find tutorials and other documentation about ASP.NET Web API OData at the ASP.NET web site.

OData Core Libraries

For OData v4, Web API now uses ODataLib version 6.5.0

New Features in ASP.NET Web API OData 5.3

Support for $levels in $expand

You can use the $levels query option in $expand queries. For example:

http://example.com/Employees?$expand=Manager($levels=2)

This query is equivalent to:

http://example.com/Employees?$expand=Manager($expand=Manager))

Support for Open Entity Types

An open type is a structured type that contains dynamic properties, in addition to any properties that are declared in the type definition. Open types let you add flexibility to your data models. For more information, see xxxx.

Support for dynamic collection properties in open types

Previously, a dynamic property had to be a single value. In 5.3, dynamic properties can have collection values. For example, in the following JSON payload, the Emails property is a dynamic property and is of collection of string type:

{
   "Id": 1,
   "Name": "Ben",
   "Emails@odata.type": "#Collection(Edm.String)",
   "Emails": [
      "a@a.com",
      "b@b.com"
   ]
}

Support for inheritance for complex types

Now complex types can inherit from a base type. For example, an OData service could define the following complex types:

public abstract class Shape
{
    public bool HasBorder { get; set; }
}

public class Point
{
    public int X { get; set; }
    public int Y { get; set; }
}

public class Circle : Shape
{
    public Point Center { get; set; }
    public int Radius { get; set; }

    public override string ToString()
    {
        return "{" + Center.X + "," + Center.Y + "," + Radius + "}";
    }
}

public class Polygon : Shape
{
    public IList<Point> Vertexes { get; set; }
    public Polygon()
    {
        Vertexes = new List<Point>();
    }
}

Here is the EDM for this example:

<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx">
  <edmx:DataServices>
    <Schema Namespace="ODataComplexTypeInheritanceSample" xmlns="http://docs.oasis-open.org/odata/ns/edm">
      <ComplexType Name="Shape" Abstract="true">
        <Property Name="HasBorder" Type="Edm.Boolean" Nullable="false" />
      </ComplexType>
      <ComplexType Name="Polygon" BaseType="ODataComplexTypeInheritanceSample.Shape">
        <Property Name="Vertexes" Type="Collection(ODataComplexTypeInheritanceSample.Point)" />
      </ComplexType>
      <ComplexType Name="Point">
        <Property Name="X" Type="Edm.Int32" Nullable="false" />
        <Property Name="Y" Type="Edm.Int32" Nullable="false" />
      </ComplexType>
      <ComplexType Name="Circle" BaseType="ODataComplexTypeInheritanceSample.Shape">
        <Property Name="Center" Type="ODataComplexTypeInheritanceSample.Point" />
        <Property Name="Radius" Type="Edm.Int32" Nullable="false" />
      </ComplexType>
      <EntityContainer Name="Container">
      </EntityContainer>
    </Schema>
  </edmx:DataServices>
</edmx:Edmx>

For more information, see OData Complex Type Inheritance Sample.

Known Issues and Breaking Changes

This section describes known issues and breaking changes in the ASP.NET Web API OData 5.3.

OData v4

Query Options

Issue: Using nested $expand with $levels=max results in an incorrect expansion depth.

For example, given the following request:

~/Entities(6)?$expand=P($levels=2;$expand=D($levels=max))

If MaxExpansionDepth is 5, this query would result in an expansion depth of 6.

Bug Fixes and Minor Feature Updates

This release also includes several bug fixes and minor feature updates.

ASP.NET Web API OData 5.3.1

In this release we made a bug fix to some of the AllowedFunctions enums. This release doesn't have any other bug fixes or new features.