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
- Documentation
- OData Core Libraries
- New Features
- Known Issues and Breaking Changes
- Bug Fixes
- ASP.NET Web API OData 5.3.1
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:
[!code-consoleMain]
1: Install-Package Microsoft.AspNet.OData -Version 5.3.0
2: Install-Package Microsoft.AspNet.WebApi.OData -Version 5.3.0
You can find tutorials and other documentation about ASP.NET Web API OData at the ASP.NET web site.
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:
[!code-consoleMain]
1: http://example.com/Employees?$expand=Manager($levels=2)
This query is equivalent to:
[!code-consoleMain]
1: http://example.com/Employees?$expand=Manager($expand=Manager))
### Support for Open Entity Types
An open type is a stuctured 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:
[!code-consoleMain]
1: {
2: "Id": 1,
3: "Name": "Ben",
4: "Emails@odata.type": "#Collection(Edm.String)",
5: "Emails": [
6: "a@a.com",
7: "b@b.com"
8: ]
9: }
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:
[!code-csharpMain]
1: public abstract class Shape
2: {
3: public bool HasBorder { get; set; }
4: }
5:
6: public class Point
7: {
8: public int X { get; set; }
9: public int Y { get; set; }
10: }
11:
12: public class Circle : Shape
13: {
14: public Point Center { get; set; }
15: public int Radius { get; set; }
16:
17: public override string ToString()
18: {
19: return "{" + Center.X + "," + Center.Y + "," + Radius + "}";
20: }
21: }
22:
23: public class Polygon : Shape
24: {
25: public IList<Point> Vertexes { get; set; }
26: public Polygon()
27: {
28: Vertexes = new List<Point>();
29: }
30: }
Here is the EDM for this example:
[!code-xmlMain]
1: <?xml version="1.0" encoding="utf-8"?>
2: <edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx">
3: <edmx:DataServices>
4: <Schema Namespace="ODataComplexTypeInheritanceSample" xmlns="http://docs.oasis-open.org/odata/ns/edm">
5: <ComplexType Name="Shape" Abstract="true">
6: <Property Name="HasBorder" Type="Edm.Boolean" Nullable="false" />
7: </ComplexType>
8: <ComplexType Name="Polygon" BaseType="ODataComplexTypeInheritanceSample.Shape">
9: <Property Name="Vertexes" Type="Collection(ODataComplexTypeInheritanceSample.Point)" />
10: </ComplexType>
11: <ComplexType Name="Point">
12: <Property Name="X" Type="Edm.Int32" Nullable="false" />
13: <Property Name="Y" Type="Edm.Int32" Nullable="false" />
14: </ComplexType>
15: <ComplexType Name="Circle" BaseType="ODataComplexTypeInheritanceSample.Shape">
16: <Property Name="Center" Type="ODataComplexTypeInheritanceSample.Point" />
17: <Property Name="Radius" Type="Edm.Int32" Nullable="false" />
18: </ComplexType>
19: <EntityContainer Name="Container">
20: </EntityContainer>
21: </Schema>
22: </edmx:DataServices>
23: </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:
[!code-consoleMain]
1: ~/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. You can find the complete list here:
## 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.
|