Monday, 22 September 2014

What’s Interesting Microsoft ASP.NET Web API 2.2 for OData v4.0 has?

Asp.net Website Development
ASP.NET is one of the best web application frameworks that marketed and developed by Microsoft. It allows programmers to create dynamic websites by using excellent programming languages like C# or VB.NET.

ASP.NET is considered as a division of the .NET Framework and when coding ASP.NET applications, one can have access to classes in the .NET Framework. Using this language, you can easily build ASP.NET applications that deliver advantages from the type safety, common language runtime, inheritance, etc.

Now, ASP.NET comes with Web API OData 5.3 that can be installed by referring below given information.

Download

Users can find the runtime features that released as NuGet packages on the NuGet gallery. Using the NuGet Package Manager Console, you can install or update to the released NuGet packages.

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

Documentation

If you are looking for tutorials and other documentation about ASP.NET Web API OData, then visit this link.

OData Core Libraries

ODataLib version 6.5.0 is used by Web API for OData v4

Some Amazing ASP.NET Web API OData 5.3 features are:
  • Support for Open Entity Types
An open type is also better known as structured type that comes with dynamic properties along with other properties that are declared in the type definition. One can simply add flexibility in their data models. For more information, see xxxx.
  • Support for $levels in $expand
The $levels query option can be easily used in $expand queries. For example:
  • Support for dynamic collection properties in open types
Previously, one can find a single value to a dynamic property. Collection values are there in dynamic properties in 5.3. If you are looking at the example, we find that in the following JSON payload, the emails property is a dynamic 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
One can inherit complex types from a base type. For example: the below given complex types could be defined by an OData service.
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>();
}
}

Check out 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>

Known Issues and Breaking Changes

The known issues and breaking changes are described in this section in the ASP.NET Web API OData 5.3.

OData v4

Query Options

Problem: the use of 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))
This query would result in an expansion depth of 6, if MaxExpansionDepth is 5.

Bug Fixes and Minor Feature Updates

Several bug fixes and minor feature updates are included in this release. For complete list, you can click here.

Are you looking for a complete Asp.net website Development solution? Then contact Perception System for adopting ‘Asp.net Developer for hire’ service.

No comments:

Post a Comment