ASP.NET Web API OData 5.3의 새로운 기능

작성자: Microsoft

이 항목에서는 ASP.NET Web API OData 5.3의 새로운 사항에 대해 설명합니다.

다운로드

런타임 기능은 NuGet 갤러리에서 NuGet 패키지로 릴리스됩니다. NuGet 패키지 관리자 콘솔을 사용하여 릴리스된 NuGet 패키지를 설치하거나 업데이트할 수 있습니다.

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

설명서

ASP.NET 웹 사이트에서 ASP.NET Web API OData에 대한 자습서 및 기타 설명서를 찾을 수 있습니다.

OData Core 라이브러리

OData v4의 경우 Web API는 이제 ODataLib 버전 6.5.0을 사용합니다.

ASP.NET Web API OData 5.3의 새로운 기능

$expand $levels 지원

$expand 쿼리에서 $levels 쿼리 옵션을 사용할 수 있습니다. 예:

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

이 쿼리는 다음과 같습니다.

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

열린 엔터티 형식 지원

열린 형식은 형식 정의에 선언된 속성 외에도 동적 속성을 포함하는 구조화된 형식입니다. 형식을 열면 데이터 모델에 유연성을 추가할 수 있습니다. 자세한 내용은 xxxx를 참조하세요.

열린 형식의 동적 컬렉션 속성 지원

이전에는 동적 속성이 단일 값이어야 했습니다. 5.3에서는 동적 속성에 컬렉션 값이 있을 수 있습니다. 예를 들어 다음 JSON 페이로드 Emails 에서 속성은 동적 속성이며 문자열 형식의 컬렉션입니다.

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

복합 형식에 대한 상속 지원

이제 복합 형식은 기본 형식에서 상속할 수 있습니다. 예를 들어 OData 서비스는 다음 복합 형식을 정의할 수 있습니다.

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>();
    }
}

이 예제의 EDM은 다음과 같습니다.

<?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>

자세한 내용은 OData 복합 형식 상속 샘플을 참조하세요.

알려진 문제 및 호환성이 손상되는 변경

이 섹션에서는 ASP.NET Web API OData 5.3의 알려진 문제 및 호환성이 손상되는 변경에 대해 설명합니다.

OData v4

쿼리 옵션

문제: $levels=max와 함께 중첩된 $expand 사용하면 확장 깊이가 잘못됩니다.

예를 들어 다음 요청이 제공됩니다.

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

가 5이면 MaxExpansionDepth 이 쿼리의 확장 깊이는 6입니다.

버그 수정 및 사소한 기능 업데이트

이 릴리스에는 몇 가지 버그 수정 및 사소한 기능 업데이트도 포함되어 있습니다.

ASP.NET Web API OData 5.3.1

이 릴리스에서는 AllowedFunctions 열거형 중 일부에 대한 버그 수정을 수행했습니다. 이 릴리스에는 다른 버그 수정 또는 새로운 기능이 없습니다.