diff --git a/.github/CONTRIBUTION.md b/.github/CONTRIBUTION.md
index 4b72fe52bd..4d778a378f 100644
--- a/.github/CONTRIBUTION.md
+++ b/.github/CONTRIBUTION.md
@@ -26,7 +26,7 @@ Pull request of features and bug fixes are both welcomed. Before you send a pull
### Complete a Contribution License Agreement (CLA)
You will need to complete a Contributor License Agreement (CLA). Briefly, this agreement testifies that you are granting us permission to use the submitted change according to the terms of the project's license, and that the work being submitted is under appropriate copyright.
-Please submit a Contributor License Agreement (CLA) before submitting a pull request. Please fill and submit the [Contribution License Agreement Form | Microsoft](https://cla.microsoft.com/). Be sure to include your GitHub user name along with the agreement. Only after we have received the signed CLA, we'll review the pull request that you send. You only need to do this once for contributing to any Microsoft open source projects.
+Please submit a Contributor License Agreement (CLA) before submitting a pull request. Please fill and submit the [Contributor License Agreement](https://cla.dotnetfoundation.org/). Be sure to include your GitHub user name along with the agreement. Only after we have received the signed CLA, we'll review the pull request that you send. This needs to only be done once for any .NET Foundation OSS project.
### Create a new issue on the issue tracker and link the pull request to it
You should have an issue created on the [issue tracker](https://github.com/OData/WebApi/issues) before you work on the pull request. After the OData Web API team has reviewed this issue and change its label to "accepting pull request", you can issue a pull request to us in which the link to the related issue is included.
diff --git a/License.txt b/License.txt
index f83934239a..feef9d0a59 100644
--- a/License.txt
+++ b/License.txt
@@ -1,6 +1,6 @@
OData-WebAPI
-Copyright (c) Microsoft. All rights reserved.
+Copyright (c) .NET Foundation and Contributors
Material in this repository is made available under the following terms:
1. Code is licensed under the MIT license, reproduced below.
@@ -23,4 +23,3 @@ NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPO
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
diff --git a/README.md b/README.md
index 20b42d1ad0..e3aa93e68d 100644
--- a/README.md
+++ b/README.md
@@ -2,8 +2,9 @@
Build | Status
--------|---------
+Odata.WebApi Rolling Dotnet pipeline |
WebApi Rolling |
-WebApi Nightly |
+WebApi Nightly |
### Introduction
@@ -118,4 +119,10 @@ Please refer to the [How to debug](https://docs.microsoft.com/en-us/odata/webapi
### Code of Conduct
-This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
+This project has adopted the [.NET Foundation Contributor Covenant Code of Conduct](https://dotnetfoundation.org/about/code-of-conduct). For more information see the [Code of Conduct FAQ](https://dotnetfoundation.org/about/faq).
+
+### .NET Foundation
+
+This project is supported by the [.NET Foundation](https://dotnetfoundation.org).
+
+WebApi is a Copyright of © .NET Foundation and other contributors. It is licensed under [MIT License](https://github.com/OData/WebApi/blob/master/License.txt)
diff --git a/configs/filelist.txt b/configs/filelist.txt
new file mode 100644
index 0000000000..bd76140b74
--- /dev/null
+++ b/configs/filelist.txt
@@ -0,0 +1 @@
+**/*.dll
\ No newline at end of file
diff --git a/images/odata.png b/images/odata.png
new file mode 100644
index 0000000000..77f9f5706f
Binary files /dev/null and b/images/odata.png differ
diff --git a/pipelines/azure_pipelines.yml b/pipelines/azure_pipelines.yml
new file mode 100644
index 0000000000..b8b4840cf6
--- /dev/null
+++ b/pipelines/azure_pipelines.yml
@@ -0,0 +1,29 @@
+trigger:
+ branches:
+ include:
+ - master
+
+resources:
+ repositories:
+ - repository: self
+ type: git
+ ref: master
+
+pr:
+ - master
+variables:
+ BuildPlatform: 'Any Cpu'
+ BuildConfiguration: 'Release'
+stages:
+- stage: Build
+ jobs:
+ - job: Main
+ displayName: Main Build
+ # setting a 3hour timeout as webapi tests normally take about 2hr 30 mins
+ timeoutInMinutes: 180
+
+ pool:
+ vmImage: windows-latest
+
+ steps:
+ - template: ./common.yml
diff --git a/pipelines/azure_pipelines_nightly.yml b/pipelines/azure_pipelines_nightly.yml
new file mode 100644
index 0000000000..f91bd4b6ad
--- /dev/null
+++ b/pipelines/azure_pipelines_nightly.yml
@@ -0,0 +1,107 @@
+schedules:
+- cron: "0 0 * * *"
+ displayName: Daily Nightly build
+ branches:
+ include:
+ - master
+resources:
+ repositories:
+ - repository: self
+ type: git
+ ref: master
+variables:
+ BuildPlatform: 'Any Cpu'
+ BuildConfiguration: 'Release'
+ RootDir: '$(Build.SourcesDirectory)'
+ ProductBinPath: '$(RootDir)\bin\$(BuildConfiguration)'
+ RELEASE_SEMANTICS: '$(ReleaseSemantics)'
+ SourcesRoot: '$(RootDir)'
+stages:
+- stage: Build
+ variables:
+ - group: SigningConfig
+ jobs:
+ - job: Main
+ displayName: Main Build
+ # setting a 3hour timeout as webapi tests normally take about 2hr 30 mins
+ timeoutInMinutes: 180
+ pool:
+ vmImage: windows-latest
+ steps:
+ - template: ./common.yml
+ - task: MSBuild@1
+ displayName: 'Get Nuget Package Metadata'
+ inputs:
+ solution: tools/GetNugetPackageMetadata.proj
+ platform: '$(BuildPlatform)'
+ configuration: '$(BuildConfiguration)'
+ - pwsh: |
+ $date = Get-Date
+ $NightlyBuildVersion = $date.ToString('yyyyMMddHHmm')
+ echo "##vso[task.setvariable variable=NightlyBuildVersion]$NightlyBuildVersion"
+ displayName: Generate Nightly Build version
+ - task: DotNetCoreCLI@2
+ displayName: Packing ASP.NET Core OData
+ inputs:
+ command: custom
+ custom: pack
+ arguments: >
+ $(RootDir)\src\Microsoft.AspNetCore.OData\Microsoft.AspNetCore.OData.csproj
+ /p:NuspecFile=$(rootDir)\src\Microsoft.AspNetCore.OData\Microsoft.AspNetCore.OData.$(RELEASE_SEMANTICS).nuspec
+ --configuration=$(buildConfiguration)
+ --output=$(Build.ArtifactStagingDirectory)\Packages
+ -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg
+
+ - task: NuGetCommand@2
+ displayName: 'Packing AspNet.OData'
+ inputs:
+ command: custom
+ arguments: pack $(RootDir)\src\Microsoft.AspNet.OData\Microsoft.AspNet.OData.$(RELEASE_SEMANTICS).nuspec -NonInteractive -OutputDirectory $(Build.ArtifactStagingDirectory)\Packages -Properties Configuration=$(BuildConfiguration);ProductRoot=$(ProductBinPath);SourcesRoot=$(Build.SourcesDirectory);VersionNuGetSemantic=$(VersionNuGetSemantic);NightlyBuildVersion=$(NightlyBuildVersion);AspNetPackageDependency="$(AspNetPackageDependency)";DependencyInjection1PackageDependency="$(DependencyInjection1PackageDependency)";ODataLibPackageDependency="$(ODataLibPackageDependency)" -Verbosity Detailed -Symbols -SymbolPackageFormat snupkg
+ - publish: $(Build.ArtifactStagingDirectory)\Packages
+ displayName: Publish Build Artifacts
+ artifact: BuildPackages
+ - pwsh: |
+ $config = "{""SignClient"":{""AzureAd"":{""AADInstance"":""$(AADInstance)"",""ClientId"":""$(ClientId)"",""TenantId"":""$(TenantId)""},""Service"":{""Url"":""https://codesign.dotnetfoundation.org/"",""ResourceId"":""$(ResourceId)""}}}"
+ $config > .\configs\SignClient.json
+ displayName: Generate Sign config
+ - publish: configs
+ displayName: Publish Signing Scripts
+ artifact: configs
+
+- stage: CodeSign
+ condition: and(succeeded('Build'), not(eq(variables['build.reason'], 'PullRequest')))
+ jobs:
+ - deployment: CodeSign
+ displayName: Code Signing
+ pool:
+ vmImage: windows-latest
+ environment: Code Sign - Approvals
+ variables:
+ - group: Code Signing
+ strategy:
+ runOnce:
+ deploy:
+ steps:
+ - task: DotNetCoreCLI@2
+ inputs:
+ command: custom
+ custom: tool
+ arguments: install --tool-path . SignClient
+ displayName: Install SignTool tool
+
+ - pwsh: |
+ .\SignClient "Sign" `
+ --baseDirectory "$(Pipeline.Workspace)\BuildPackages" `
+ --input "**/*.nupkg" `
+ --config "$(Pipeline.Workspace)\configs\SignClient.json" `
+ --filelist "$(Pipeline.Workspace)\configs\filelist.txt" `
+ --user "$(SignClientUser)" `
+ --secret "$(SignClientSecret)" `
+ --name "Code Sign packages" `
+ --description "Signing packages" `
+ --descriptionUrl "https://github.com/OData/WebApi"
+ displayName: Sign packages
+
+ - publish: $(Pipeline.Workspace)/BuildPackages
+ displayName: Publish Signed Packages
+ artifact: SignedPackages
diff --git a/pipelines/common.yml b/pipelines/common.yml
new file mode 100644
index 0000000000..d158498172
--- /dev/null
+++ b/pipelines/common.yml
@@ -0,0 +1,121 @@
+steps:
+- checkout: self
+
+- task: NuGetToolInstaller@1
+ displayName: Use NuGet >=5.2.0
+ inputs:
+ versionSpec: '>=5.2.0'
+ checkLatest: true
+
+- task: UseDotNet@2
+ displayName: Use .NET Core sdk 3.1
+ inputs:
+ version: 3.x
+
+- task: UseDotNet@2
+ displayName: Use .NET Core sdk 2.0.x
+ inputs:
+ version: 2.0.x
+
+- task: UseDotNet@2
+ displayName: Use .NET Core sdk 5.x
+ inputs:
+ version: 5.x
+ includePreviewVersions: true
+
+- task: NuGetCommand@2
+ displayName: 'NuGet restore **\*.sln'
+ inputs:
+ restoreSolution: 'sln/WebApiOData.AspNet.sln;sln/WebApiOData.AspNetCore.sln;sln/WebApiOData.E2E.AspNet.sln;sln/WebApiOData.E2E.AspNetCore.sln'
+
+- task: VSBuild@1
+ displayName: 'Build solution sln\WebApiOData.AspNet.sln'
+ inputs:
+ solution: 'sln\WebApiOData.AspNet.sln '
+ platform: '$(BuildPlatform)'
+ configuration: '$(BuildConfiguration)'
+
+- task: VSBuild@1
+ displayName: 'Build solution sln\WebApiOData.E2E.AspNet.sln'
+ inputs:
+ solution: 'sln\WebApiOData.E2E.AspNet.sln'
+ platform: '$(BuildPlatform)'
+ configuration: '$(BuildConfiguration)'
+
+- task: DotNetCoreCLI@2
+ displayName: 'Build Microsoft.AspNetCore.OData.csproj '
+ inputs:
+ projects: '$(Build.SourcesDirectory)\src\Microsoft.AspNetCore.OData\Microsoft.AspNetCore.OData.csproj'
+ arguments: '--configuration $(BuildConfiguration) --no-incremental'
+
+- task: DotNetCoreCLI@2
+ displayName: 'Build .NET Core Unit test project'
+ inputs:
+ projects: '$(Build.SourcesDirectory)\test\UnitTest\Microsoft.AspNetCore.OData.Test\Microsoft.AspNetCore.OData.Test.csproj'
+ arguments: '--configuration $(BuildConfiguration) --no-incremental'
+
+- task: DotNetCoreCLI@2
+ displayName: 'Build .NET Core E2E test project'
+ inputs:
+ projects: '$(Build.SourcesDirectory)\test\E2ETest\Microsoft.Test.E2E.AspNet.OData\Build.AspNetCore\Microsoft.Test.E2E.AspNetCore.OData.csproj'
+ arguments: '--configuration $(BuildConfiguration) --no-incremental'
+
+- task: DotNetCoreCLI@2
+ displayName: 'Build .NET Core 3x E2E test project'
+ inputs:
+ projects: '$(Build.SourcesDirectory)\test\E2ETest\Microsoft.Test.E2E.AspNet.OData\Build.AspNetCore3x\Microsoft.Test.E2E.AspNetCore3x.OData.csproj'
+ arguments: '--configuration $(BuildConfiguration) --no-incremental'
+
+- powershell: |
+ $PROGRAMFILESX86 = [Environment]::GetFolderPath("ProgramFilesX86")
+
+ $SN = $PROGRAMFILESX86 + "\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\sn.exe"
+ $SNx64 = $PROGRAMFILESX86 + "\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\x64\sn.exe"
+
+ & $SN /Vr $(Build.SourcesDirectory)\bin\Release\Microsoft.AspNet.OData.dll
+ & $SNx64 /Vr $(Build.SourcesDirectory)\bin\Release\Microsoft.AspNet.OData.dll
+
+ & $SN /Vr $(Build.SourcesDirectory)\bin\release\netstandard2.0\Microsoft.AspNetCore.OData.dll
+ & $SNx64 /Vr $(Build.SourcesDirectory)\bin\release\netstandard2.0\Microsoft.AspNetCore.OData.dll
+
+ & $SN /Vr $(Build.SourcesDirectory)\bin\Release\UnitTest\AspNet\Microsoft.AspNet.OData.Test.dll
+ & $SNx64 /Vr $(Build.SourcesDirectory)\bin\Release\UnitTest\AspNet\Microsoft.AspNet.OData.Test.dll
+
+ & $SN /Vr $(Build.SourcesDirectory)\bin\Release\E2ETest\AspNet\Microsoft.Test.E2E.AspNet.OData.dll
+ & $SNx64 /Vr $(Build.SourcesDirectory)\bin\Release\E2ETest\AspNet\Microsoft.Test.E2E.AspNet.OData.dll
+
+ & $SN /Vr $(Build.SourcesDirectory)\bin\release\E2ETest\AspNetCore\Microsoft.Test.E2E.AspNetCore.OData.dll
+ & $SNx64 /Vr $(Build.SourcesDirectory)\bin\release\E2ETest\AspNetCore\Microsoft.Test.E2E.AspNetCore.OData.dll
+ displayName: 'Skip StrongName for Classic'
+
+- task: DotNetCoreCLI@2
+ displayName: 'Core E2E Tests (Microsoft.Test.E2E.AspNetCore.OData.csproj)'
+ inputs:
+ command: test
+ projects: '$(Build.SourcesDirectory)\test\E2ETest\Microsoft.Test.E2E.AspNet.OData\Build.AspNetCore\Microsoft.Test.E2E.AspNetCore.OData.csproj'
+ arguments: '--configuration $(BuildConfiguration) --no-build'
+
+- task: DotNetCoreCLI@2
+ displayName: 'Core E2E 3x Tests (Microsoft.Test.E2E.AspNetCore3x.OData.csproj)'
+ inputs:
+ command: test
+ projects: '$(Build.SourcesDirectory)\test\E2ETest\Microsoft.Test.E2E.AspNet.OData\Build.AspNetCore3x\Microsoft.Test.E2E.AspNetCore3x.OData.csproj'
+ arguments: '--configuration $(BuildConfiguration) --no-build --filter FullyQualifiedName!=Microsoft.Test.E2E.AspNet.OData.QueryComposition.SelectExpandEFTests.QueryForLongSelectList -v diag'
+
+- task: VSTest@2
+ displayName: 'Classic Unit Tests (Microsoft.AspNet.OData.Test.dll)'
+ inputs:
+ testAssemblyVer2: '**\bin\**\UnitTest\**\Microsoft.AspNet.OData.Test.dll'
+
+- task: DotNetCoreCLI@2
+ displayName: 'Core Unit Tests (Microsoft.AspNetCore.OData.Test.csproj) '
+ inputs:
+ command: test
+ projects: '$(Build.SourcesDirectory)\test\UnitTest\Microsoft.AspNetCore.OData.Test\Microsoft.AspNetCore.OData.Test.csproj'
+ arguments: '--configuration $(BuildConfiguration) --no-build'
+
+- task: VSTest@2
+ displayName: 'Classic E2E Tests (Microsoft.Test.E2E.AspNet.OData.dll)'
+ inputs:
+ testAssemblyVer2: '**\bin\**\E2ETest\**\Microsoft.Test.E2E.AspNet.OData.dll'
+ testFiltercriteria: '(DisplayName!=Microsoft.Test.E2E.AspNet.OData.ODataPathHandler.UnicodeRouteTests_Todoü.CRUDEntitySetShouldWork)'
diff --git a/samples/AspNetCore3xEndpointSample.Web/Controllers/CustomersController.cs b/samples/AspNetCore3xEndpointSample.Web/Controllers/CustomersController.cs
index b6b21f526f..c84e090d70 100644
--- a/samples/AspNetCore3xEndpointSample.Web/Controllers/CustomersController.cs
+++ b/samples/AspNetCore3xEndpointSample.Web/Controllers/CustomersController.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Linq;
diff --git a/samples/AspNetCore3xEndpointSample.Web/Controllers/ODataOperationImportController.cs b/samples/AspNetCore3xEndpointSample.Web/Controllers/ODataOperationImportController.cs
index 4242291372..2ba4f467c6 100644
--- a/samples/AspNetCore3xEndpointSample.Web/Controllers/ODataOperationImportController.cs
+++ b/samples/AspNetCore3xEndpointSample.Web/Controllers/ODataOperationImportController.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData;
using Microsoft.AspNetCore.Mvc;
diff --git a/samples/AspNetCore3xEndpointSample.Web/Controllers/WeatherForecastController.cs b/samples/AspNetCore3xEndpointSample.Web/Controllers/WeatherForecastController.cs
index cda9f1e032..b4785780bd 100644
--- a/samples/AspNetCore3xEndpointSample.Web/Controllers/WeatherForecastController.cs
+++ b/samples/AspNetCore3xEndpointSample.Web/Controllers/WeatherForecastController.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/samples/AspNetCore3xEndpointSample.Web/Models/CustomerOrder.cs b/samples/AspNetCore3xEndpointSample.Web/Models/CustomerOrder.cs
index 5ac809cf4f..389d1ed14f 100644
--- a/samples/AspNetCore3xEndpointSample.Web/Models/CustomerOrder.cs
+++ b/samples/AspNetCore3xEndpointSample.Web/Models/CustomerOrder.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
diff --git a/samples/AspNetCore3xEndpointSample.Web/Models/CustomerOrderContext.cs b/samples/AspNetCore3xEndpointSample.Web/Models/CustomerOrderContext.cs
index 6c6e4fff2e..cff7a88407 100644
--- a/samples/AspNetCore3xEndpointSample.Web/Models/CustomerOrderContext.cs
+++ b/samples/AspNetCore3xEndpointSample.Web/Models/CustomerOrderContext.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.EntityFrameworkCore;
diff --git a/samples/AspNetCore3xEndpointSample.Web/Models/EdmModelBuilder.cs b/samples/AspNetCore3xEndpointSample.Web/Models/EdmModelBuilder.cs
index 5335e1d89e..5fdea7dcd4 100644
--- a/samples/AspNetCore3xEndpointSample.Web/Models/EdmModelBuilder.cs
+++ b/samples/AspNetCore3xEndpointSample.Web/Models/EdmModelBuilder.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Builder;
using Microsoft.OData.Edm;
@@ -39,4 +43,4 @@ public static IEdmModel GetEdmModel()
}
}
-}
\ No newline at end of file
+}
diff --git a/samples/AspNetCore3xEndpointSample.Web/Models/WeatherForecast.cs b/samples/AspNetCore3xEndpointSample.Web/Models/WeatherForecast.cs
index f0a79b337f..5d97a14fa6 100644
--- a/samples/AspNetCore3xEndpointSample.Web/Models/WeatherForecast.cs
+++ b/samples/AspNetCore3xEndpointSample.Web/Models/WeatherForecast.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
diff --git a/samples/AspNetCore3xEndpointSample.Web/Program.cs b/samples/AspNetCore3xEndpointSample.Web/Program.cs
index fe23386a20..3ac68f4c90 100644
--- a/samples/AspNetCore3xEndpointSample.Web/Program.cs
+++ b/samples/AspNetCore3xEndpointSample.Web/Program.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
diff --git a/samples/AspNetCore3xEndpointSample.Web/Startup.cs b/samples/AspNetCore3xEndpointSample.Web/Startup.cs
index 667d735e05..e0a5392ee0 100644
--- a/samples/AspNetCore3xEndpointSample.Web/Startup.cs
+++ b/samples/AspNetCore3xEndpointSample.Web/Startup.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/samples/AspNetCore3xODataSample.Web/Controllers/CustomersController.cs b/samples/AspNetCore3xODataSample.Web/Controllers/CustomersController.cs
index 6eda606d3d..e88fdcb4f6 100644
--- a/samples/AspNetCore3xODataSample.Web/Controllers/CustomersController.cs
+++ b/samples/AspNetCore3xODataSample.Web/Controllers/CustomersController.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Linq;
diff --git a/samples/AspNetCore3xODataSample.Web/Models/CustomerOrder.cs b/samples/AspNetCore3xODataSample.Web/Models/CustomerOrder.cs
index ea9ba905ae..d7e3931782 100644
--- a/samples/AspNetCore3xODataSample.Web/Models/CustomerOrder.cs
+++ b/samples/AspNetCore3xODataSample.Web/Models/CustomerOrder.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
diff --git a/samples/AspNetCore3xODataSample.Web/Models/CustomerOrderContext.cs b/samples/AspNetCore3xODataSample.Web/Models/CustomerOrderContext.cs
index 1cdb7293c9..0300cf37d4 100644
--- a/samples/AspNetCore3xODataSample.Web/Models/CustomerOrderContext.cs
+++ b/samples/AspNetCore3xODataSample.Web/Models/CustomerOrderContext.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.EntityFrameworkCore;
diff --git a/samples/AspNetCore3xODataSample.Web/Models/EdmModelBuilder.cs b/samples/AspNetCore3xODataSample.Web/Models/EdmModelBuilder.cs
index 9fa9080c25..b6e144eac9 100644
--- a/samples/AspNetCore3xODataSample.Web/Models/EdmModelBuilder.cs
+++ b/samples/AspNetCore3xODataSample.Web/Models/EdmModelBuilder.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Builder;
using Microsoft.OData.Edm;
@@ -24,4 +28,4 @@ public static IEdmModel GetEdmModel()
}
}
-}
\ No newline at end of file
+}
diff --git a/samples/AspNetCore3xODataSample.Web/Program.cs b/samples/AspNetCore3xODataSample.Web/Program.cs
index 8368ae5f26..7aa097645f 100644
--- a/samples/AspNetCore3xODataSample.Web/Program.cs
+++ b/samples/AspNetCore3xODataSample.Web/Program.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
diff --git a/samples/AspNetCore3xODataSample.Web/Startup.cs b/samples/AspNetCore3xODataSample.Web/Startup.cs
index b8051e2e6b..c35dfcd152 100644
--- a/samples/AspNetCore3xODataSample.Web/Startup.cs
+++ b/samples/AspNetCore3xODataSample.Web/Startup.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using AspNetCore3xODataSample.Web.Models;
using Microsoft.AspNet.OData.Extensions;
diff --git a/samples/AspNetCoreODataSample.Web/Controllers/CustomersController.cs b/samples/AspNetCoreODataSample.Web/Controllers/CustomersController.cs
index c30cccbaf6..8753cadb9e 100644
--- a/samples/AspNetCoreODataSample.Web/Controllers/CustomersController.cs
+++ b/samples/AspNetCoreODataSample.Web/Controllers/CustomersController.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Linq;
diff --git a/samples/AspNetCoreODataSample.Web/Controllers/MoviesController.cs b/samples/AspNetCoreODataSample.Web/Controllers/MoviesController.cs
index bdf2af60d2..4449b721b9 100644
--- a/samples/AspNetCoreODataSample.Web/Controllers/MoviesController.cs
+++ b/samples/AspNetCoreODataSample.Web/Controllers/MoviesController.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/samples/AspNetCoreODataSample.Web/Controllers/PeopleController.cs b/samples/AspNetCoreODataSample.Web/Controllers/PeopleController.cs
index cf2848eed7..58902a17ba 100644
--- a/samples/AspNetCoreODataSample.Web/Controllers/PeopleController.cs
+++ b/samples/AspNetCoreODataSample.Web/Controllers/PeopleController.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using AspNetCoreODataSample.Web.Models;
diff --git a/samples/AspNetCoreODataSample.Web/Models/CustomerOrderModel.cs b/samples/AspNetCoreODataSample.Web/Models/CustomerOrderModel.cs
index fb9f1c1d23..de17bd5ea3 100644
--- a/samples/AspNetCoreODataSample.Web/Models/CustomerOrderModel.cs
+++ b/samples/AspNetCoreODataSample.Web/Models/CustomerOrderModel.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
diff --git a/samples/AspNetCoreODataSample.Web/Models/EdmModelBuilder.cs b/samples/AspNetCoreODataSample.Web/Models/EdmModelBuilder.cs
index 1a9c0c091c..467413771d 100644
--- a/samples/AspNetCoreODataSample.Web/Models/EdmModelBuilder.cs
+++ b/samples/AspNetCoreODataSample.Web/Models/EdmModelBuilder.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Builder;
using Microsoft.OData.Edm;
diff --git a/samples/AspNetCoreODataSample.Web/Models/Genre.cs b/samples/AspNetCoreODataSample.Web/Models/Genre.cs
index 0036c433a7..b59ab7fd0e 100644
--- a/samples/AspNetCoreODataSample.Web/Models/Genre.cs
+++ b/samples/AspNetCoreODataSample.Web/Models/Genre.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
namespace AspNetCoreODataSample.Web.Models
{
diff --git a/samples/AspNetCoreODataSample.Web/Models/Level.cs b/samples/AspNetCoreODataSample.Web/Models/Level.cs
index 50da049367..1c3b27de78 100644
--- a/samples/AspNetCoreODataSample.Web/Models/Level.cs
+++ b/samples/AspNetCoreODataSample.Web/Models/Level.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Runtime.Serialization;
diff --git a/samples/AspNetCoreODataSample.Web/Models/Movie.cs b/samples/AspNetCoreODataSample.Web/Models/Movie.cs
index d584a37ac8..6ce6fcf0a3 100644
--- a/samples/AspNetCoreODataSample.Web/Models/Movie.cs
+++ b/samples/AspNetCoreODataSample.Web/Models/Movie.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/samples/AspNetCoreODataSample.Web/Models/MovieContext.cs b/samples/AspNetCoreODataSample.Web/Models/MovieContext.cs
index f76826a0a1..5af64f6690 100644
--- a/samples/AspNetCoreODataSample.Web/Models/MovieContext.cs
+++ b/samples/AspNetCoreODataSample.Web/Models/MovieContext.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.EntityFrameworkCore;
diff --git a/samples/AspNetCoreODataSample.Web/Models/MovieStar.cs b/samples/AspNetCoreODataSample.Web/Models/MovieStar.cs
index 99893f548d..de8a2b60de 100644
--- a/samples/AspNetCoreODataSample.Web/Models/MovieStar.cs
+++ b/samples/AspNetCoreODataSample.Web/Models/MovieStar.cs
@@ -1,4 +1,11 @@
-namespace AspNetCoreODataSample.Web.Models
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
+
+namespace AspNetCoreODataSample.Web.Models
{
public class MovieStar
{
@@ -10,4 +17,4 @@ public class MovieStar
public string LastName { get; set; }
}
-}
\ No newline at end of file
+}
diff --git a/samples/AspNetCoreODataSample.Web/Models/Person.cs b/samples/AspNetCoreODataSample.Web/Models/Person.cs
index fbcee7242c..9130d9c6b7 100644
--- a/samples/AspNetCoreODataSample.Web/Models/Person.cs
+++ b/samples/AspNetCoreODataSample.Web/Models/Person.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
diff --git a/samples/AspNetCoreODataSample.Web/Program.cs b/samples/AspNetCoreODataSample.Web/Program.cs
index 4772a7368b..f3adf83994 100644
--- a/samples/AspNetCoreODataSample.Web/Program.cs
+++ b/samples/AspNetCoreODataSample.Web/Program.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
diff --git a/samples/AspNetCoreODataSample.Web/Startup.cs b/samples/AspNetCoreODataSample.Web/Startup.cs
index 6518f0198b..a2e41ad9d9 100644
--- a/samples/AspNetCoreODataSample.Web/Startup.cs
+++ b/samples/AspNetCoreODataSample.Web/Startup.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
diff --git a/samples/AspNetODataSample.Web/App_Start/WebApiConfig.cs b/samples/AspNetODataSample.Web/App_Start/WebApiConfig.cs
index 7a1355dc59..99d72a5e0a 100644
--- a/samples/AspNetODataSample.Web/App_Start/WebApiConfig.cs
+++ b/samples/AspNetODataSample.Web/App_Start/WebApiConfig.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Web.Http;
using AspNetODataSample.Web.Models;
diff --git a/samples/AspNetODataSample.Web/AspNetODataSample.Web.csproj b/samples/AspNetODataSample.Web/AspNetODataSample.Web.csproj
index ec9a437faf..028797ecc0 100644
--- a/samples/AspNetODataSample.Web/AspNetODataSample.Web.csproj
+++ b/samples/AspNetODataSample.Web/AspNetODataSample.Web.csproj
@@ -88,16 +88,23 @@
True
-
- ..\..\sln\packages\Microsoft.OData.Core.7.9.0\lib\net45\Microsoft.OData.Core.dll
+
+ ..\..\sln\packages\Microsoft.OData.Core.7.9.1\lib\net45\Microsoft.OData.Core.dll
-
- ..\..\sln\packages\Microsoft.OData.Edm.7.9.0\lib\net45\Microsoft.OData.Edm.dll
+
+ ..\..\sln\packages\Microsoft.OData.Edm.7.9.1\lib\net45\Microsoft.OData.Edm.dll
..\..\sln\packages\Microsoft.Spatial.7.9.0\lib\net45\Microsoft.Spatial.dll
+ ..\..\sln\packages\Microsoft.Spatial.7.9.1\lib\net45\Microsoft.Spatial.dll
True
+
+ ..\..\sln\packages\System.Buffers.4.5.0\lib\netstandard2.0\System.Buffers.dll
+
+
+ ..\..\sln\packages\System.Buffers.4.5.0\lib\netstandard2.0\System.Buffers.dll
+
..\..\sln\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll
diff --git a/samples/AspNetODataSample.Web/Controllers/ODataOperationImportController.cs b/samples/AspNetODataSample.Web/Controllers/ODataOperationImportController.cs
index 3f5c71079b..97d90bdda9 100644
--- a/samples/AspNetODataSample.Web/Controllers/ODataOperationImportController.cs
+++ b/samples/AspNetODataSample.Web/Controllers/ODataOperationImportController.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Linq;
using System.Web.Http;
@@ -16,4 +20,4 @@ public IHttpActionResult RateByOrder(int order)
return Ok($"In RateByOrder using Order = {order}");
}
}
-}
\ No newline at end of file
+}
diff --git a/samples/AspNetODataSample.Web/Controllers/TodoItemsController.cs b/samples/AspNetODataSample.Web/Controllers/TodoItemsController.cs
index 88848fdabb..ba4fd8a00d 100644
--- a/samples/AspNetODataSample.Web/Controllers/TodoItemsController.cs
+++ b/samples/AspNetODataSample.Web/Controllers/TodoItemsController.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Linq;
using System.Web.Http;
@@ -45,4 +49,4 @@ public IHttpActionResult Post(TodoItem item)
return Created(item);
}
}
-}
\ No newline at end of file
+}
diff --git a/samples/AspNetODataSample.Web/Global.asax.cs b/samples/AspNetODataSample.Web/Global.asax.cs
index a75bb47339..570817d199 100644
--- a/samples/AspNetODataSample.Web/Global.asax.cs
+++ b/samples/AspNetODataSample.Web/Global.asax.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Web.Http;
diff --git a/samples/AspNetODataSample.Web/Models/DataSource.cs b/samples/AspNetODataSample.Web/Models/DataSource.cs
index dda8357516..91d1e174db 100644
--- a/samples/AspNetODataSample.Web/Models/DataSource.cs
+++ b/samples/AspNetODataSample.Web/Models/DataSource.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
@@ -42,4 +46,4 @@ public static IList GetTodoItems()
return _items;
}
}
-}
\ No newline at end of file
+}
diff --git a/samples/AspNetODataSample.Web/Models/EdmModelBuilder.cs b/samples/AspNetODataSample.Web/Models/EdmModelBuilder.cs
index 26c65f3553..bd0553bc43 100644
--- a/samples/AspNetODataSample.Web/Models/EdmModelBuilder.cs
+++ b/samples/AspNetODataSample.Web/Models/EdmModelBuilder.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Builder;
using Microsoft.OData.Edm;
@@ -26,4 +30,4 @@ public static IEdmModel GetEdmModel()
return _model;
}
}
-}
\ No newline at end of file
+}
diff --git a/samples/AspNetODataSample.Web/Models/TodoItem.cs b/samples/AspNetODataSample.Web/Models/TodoItem.cs
index a694c28eaa..ecb91e9c44 100644
--- a/samples/AspNetODataSample.Web/Models/TodoItem.cs
+++ b/samples/AspNetODataSample.Web/Models/TodoItem.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
namespace AspNetODataSample.Web.Models
{
@@ -9,4 +13,4 @@ public class TodoItem
public string Name { get; set; }
public bool IsComplete { get; set; }
}
-}
\ No newline at end of file
+}
diff --git a/samples/AspNetODataSample.Web/Models/TodoItemContext.cs b/samples/AspNetODataSample.Web/Models/TodoItemContext.cs
index 98831347e1..e658caa153 100644
--- a/samples/AspNetODataSample.Web/Models/TodoItemContext.cs
+++ b/samples/AspNetODataSample.Web/Models/TodoItemContext.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Data.Entity;
@@ -9,4 +13,4 @@ public class TodoItemContext : DbContext
{
public DbSet TodoItems { get; set; }
}
-}
\ No newline at end of file
+}
diff --git a/samples/AspNetODataSample.Web/Properties/AssemblyInfo.cs b/samples/AspNetODataSample.Web/Properties/AssemblyInfo.cs
index 6c6e473732..67f61cde26 100644
--- a/samples/AspNetODataSample.Web/Properties/AssemblyInfo.cs
+++ b/samples/AspNetODataSample.Web/Properties/AssemblyInfo.cs
@@ -1,4 +1,11 @@
-using System.Reflection;
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
+
+using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -10,7 +17,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AspNetODataSample.Web")]
-[assembly: AssemblyCopyright("Copyright © 2018")]
+[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
diff --git a/samples/AspNetODataSample.Web/Web.config b/samples/AspNetODataSample.Web/Web.config
index e7cb3db212..2a98e0bd9a 100644
--- a/samples/AspNetODataSample.Web/Web.config
+++ b/samples/AspNetODataSample.Web/Web.config
@@ -4,85 +4,89 @@
http://go.microsoft.com/fwlink/?LinkId=301879
-->
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/AspNetODataSample.Web/packages.config b/samples/AspNetODataSample.Web/packages.config
index eb858a6251..0e99202ef2 100644
--- a/samples/AspNetODataSample.Web/packages.config
+++ b/samples/AspNetODataSample.Web/packages.config
@@ -15,9 +15,9 @@
-
-
-
+
+
+
diff --git a/src/CommonAssemblyInfo.cs b/src/CommonAssemblyInfo.cs
index 522a341f32..d9467db637 100644
--- a/src/CommonAssemblyInfo.cs
+++ b/src/CommonAssemblyInfo.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Reflection;
diff --git a/src/GlobalSuppressions.cs b/src/GlobalSuppressions.cs
index ccb18befdd..1558193e78 100644
--- a/src/GlobalSuppressions.cs
+++ b/src/GlobalSuppressions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Diagnostics.CodeAnalysis;
diff --git a/src/Microsoft.AspNet.OData.Shared/Batch/ODataBatchContent.cs b/src/Microsoft.AspNet.OData.Shared/Batch/ODataBatchContent.cs
index ee8abb0e8f..d3238655e0 100644
--- a/src/Microsoft.AspNet.OData.Shared/Batch/ODataBatchContent.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Batch/ODataBatchContent.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
@@ -60,4 +64,4 @@ private async Task WriteToResponseMessageAsync(IODataResponseMessage responseMes
await writer.WriteEndBatchAsync();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/Batch/ODataBatchHandler.cs b/src/Microsoft.AspNet.OData.Shared/Batch/ODataBatchHandler.cs
index af04043da0..fd84167352 100644
--- a/src/Microsoft.AspNet.OData.Shared/Batch/ODataBatchHandler.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Batch/ODataBatchHandler.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Interfaces;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/ActionConfiguration.cs b/src/Microsoft.AspNet.OData.Shared/Builder/ActionConfiguration.cs
index 4d117676e8..fbe1975ee1 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/ActionConfiguration.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/ActionConfiguration.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/ActionOnDeleteAttribute.cs b/src/Microsoft.AspNet.OData.Shared/Builder/ActionOnDeleteAttribute.cs
index 7de1e0b302..f27cb02028 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/ActionOnDeleteAttribute.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/ActionOnDeleteAttribute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.OData.Edm;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/AutoExpandAttribute.cs b/src/Microsoft.AspNet.OData.Shared/Builder/AutoExpandAttribute.cs
index dfa4159679..ccc4b34356 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/AutoExpandAttribute.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/AutoExpandAttribute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/BindableOperationFinder.cs b/src/Microsoft.AspNet.OData.Shared/Builder/BindableOperationFinder.cs
index bc1bcab5a4..85cac5803e 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/BindableOperationFinder.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/BindableOperationFinder.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Linq;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/BindingParameterConfiguration.cs b/src/Microsoft.AspNet.OData.Shared/Builder/BindingParameterConfiguration.cs
index e14b343518..9f75f1ba52 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/BindingParameterConfiguration.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/BindingParameterConfiguration.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Common;
using Microsoft.OData.Edm;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/BindingPathConfigurationOfTStructuralType.cs b/src/Microsoft.AspNet.OData.Shared/Builder/BindingPathConfigurationOfTStructuralType.cs
index ebd9a9f733..ab39b7ef12 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/BindingPathConfigurationOfTStructuralType.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/BindingPathConfigurationOfTStructuralType.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/BindingPathHelper.cs b/src/Microsoft.AspNet.OData.Shared/Builder/BindingPathHelper.cs
index 3fe7eb64a6..60da3fc64d 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/BindingPathHelper.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/BindingPathHelper.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/CapabilitiesNavigationType.cs b/src/Microsoft.AspNet.OData.Shared/Builder/CapabilitiesNavigationType.cs
index 7aa60add38..a0205ebba3 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/CapabilitiesNavigationType.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/CapabilitiesNavigationType.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
namespace Microsoft.AspNet.OData.Builder
{
@@ -23,4 +27,4 @@ internal enum CapabilitiesNavigationType
///
None
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/CapabilitiesVocabularyConstants.cs b/src/Microsoft.AspNet.OData.Shared/Builder/CapabilitiesVocabularyConstants.cs
index 0a4f19ad9f..e1b0c55111 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/CapabilitiesVocabularyConstants.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/CapabilitiesVocabularyConstants.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
namespace Microsoft.AspNet.OData.Builder
{
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/CapabilitiesVocabularyExtensionMethods.cs b/src/Microsoft.AspNet.OData.Shared/Builder/CapabilitiesVocabularyExtensionMethods.cs
index df75bb3867..36e5c6a20d 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/CapabilitiesVocabularyExtensionMethods.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/CapabilitiesVocabularyExtensionMethods.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/CollectionPropertyConfiguration.cs b/src/Microsoft.AspNet.OData.Shared/Builder/CollectionPropertyConfiguration.cs
index 18eb976e8e..06d40326eb 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/CollectionPropertyConfiguration.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/CollectionPropertyConfiguration.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Reflection;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/CollectionTypeConfiguration.cs b/src/Microsoft.AspNet.OData.Shared/Builder/CollectionTypeConfiguration.cs
index 8c86672ec2..67c92ddbdc 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/CollectionTypeConfiguration.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/CollectionTypeConfiguration.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Globalization;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/ComplexPropertyConfiguration.cs b/src/Microsoft.AspNet.OData.Shared/Builder/ComplexPropertyConfiguration.cs
index e2034f0dd5..39f5439d86 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/ComplexPropertyConfiguration.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/ComplexPropertyConfiguration.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Reflection;
@@ -74,4 +78,4 @@ public ComplexPropertyConfiguration HasDerivedTypeConstraint()
return this;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/ComplexTypeConfiguration.cs b/src/Microsoft.AspNet.OData.Shared/Builder/ComplexTypeConfiguration.cs
index ead59e4b9e..0fde2a585c 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/ComplexTypeConfiguration.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/ComplexTypeConfiguration.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.OData.Edm;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/ComplexTypeConfigurationOfTComplexType.cs b/src/Microsoft.AspNet.OData.Shared/Builder/ComplexTypeConfigurationOfTComplexType.cs
index 88e3d39b24..200ac639ad 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/ComplexTypeConfigurationOfTComplexType.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/ComplexTypeConfigurationOfTComplexType.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/ContainedAttribute.cs b/src/Microsoft.AspNet.OData.Shared/Builder/ContainedAttribute.cs
index 1a12515f80..a237c9fa72 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/ContainedAttribute.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/ContainedAttribute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/ContainmentPathBuilder.cs b/src/Microsoft.AspNet.OData.Shared/Builder/ContainmentPathBuilder.cs
index 0d76f38b92..07862bf96c 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/ContainmentPathBuilder.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/ContainmentPathBuilder.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Diagnostics.Contracts;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/AbstractEntityTypeDiscoveryConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/AbstractEntityTypeDiscoveryConvention.cs
index 809520dff3..559388f47f 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/AbstractEntityTypeDiscoveryConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/AbstractEntityTypeDiscoveryConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
namespace Microsoft.AspNet.OData.Builder.Conventions
{
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/AbstractTypeDiscoveryConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/AbstractTypeDiscoveryConvention.cs
index 40c984aeb5..ff97a93db4 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/AbstractTypeDiscoveryConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/AbstractTypeDiscoveryConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
namespace Microsoft.AspNet.OData.Builder.Conventions
{
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/ActionLinkGenerationConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/ActionLinkGenerationConvention.cs
index 554b1837fc..0e83286a65 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/ActionLinkGenerationConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/ActionLinkGenerationConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.OData.Edm;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/AssociationSetDiscoveryConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/AssociationSetDiscoveryConvention.cs
index f3732a22a6..80fa0ac84a 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/AssociationSetDiscoveryConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/AssociationSetDiscoveryConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/ActionOnDeleteAttributeConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/ActionOnDeleteAttributeConvention.cs
index 3d556fcbdc..ef252528c3 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/ActionOnDeleteAttributeConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/ActionOnDeleteAttributeConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Linq;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/AttributeConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/AttributeConvention.cs
index fba65b6eab..21646d1278 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/AttributeConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/AttributeConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Linq;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/AttributeEdmPropertyConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/AttributeEdmPropertyConvention.cs
index ef3348c992..f49ff696fd 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/AttributeEdmPropertyConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/AttributeEdmPropertyConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/AttributeEdmTypeConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/AttributeEdmTypeConvention.cs
index f4ac7acea8..6cf65266ac 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/AttributeEdmTypeConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/AttributeEdmTypeConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/AutoExpandAttributeEdmPropertyConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/AutoExpandAttributeEdmPropertyConvention.cs
index a5ef2e7263..b93e991f61 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/AutoExpandAttributeEdmPropertyConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/AutoExpandAttributeEdmPropertyConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/AutoExpandAttributeEdmTypeConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/AutoExpandAttributeEdmTypeConvention.cs
index ab4ec21c76..21a6c9042a 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/AutoExpandAttributeEdmTypeConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/AutoExpandAttributeEdmTypeConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/ColumnAttributeEdmPropertyConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/ColumnAttributeEdmPropertyConvention.cs
index 799be114f7..28a1dd6705 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/ColumnAttributeEdmPropertyConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/ColumnAttributeEdmPropertyConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.ComponentModel.DataAnnotations.Schema;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/ComplexTypeAttributeConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/ComplexTypeAttributeConvention.cs
index 7ec7f93fe3..75013de5f2 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/ComplexTypeAttributeConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/ComplexTypeAttributeConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.ComponentModel.DataAnnotations.Schema;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/ConcurrencyCheckAttributeEdmPropertyConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/ConcurrencyCheckAttributeEdmPropertyConvention.cs
index cbea8b615d..f1a08547e1 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/ConcurrencyCheckAttributeEdmPropertyConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/ConcurrencyCheckAttributeEdmPropertyConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.ComponentModel.DataAnnotations;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/CountAttributeEdmPropertyConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/CountAttributeEdmPropertyConvention.cs
index 8828782c8b..641d5aa649 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/CountAttributeEdmPropertyConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/CountAttributeEdmPropertyConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/CountAttributeEdmTypeConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/CountAttributeEdmTypeConvention.cs
index 27c4762c8a..dba23d1945 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/CountAttributeEdmTypeConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/CountAttributeEdmTypeConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/DataContractAttributeEdmTypeConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/DataContractAttributeEdmTypeConvention.cs
index 642581dded..690d1b25f6 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/DataContractAttributeEdmTypeConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/DataContractAttributeEdmTypeConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/DataContractAttributeEnumTypeConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/DataContractAttributeEnumTypeConvention.cs
index 1cc236c1a2..a614f16a44 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/DataContractAttributeEnumTypeConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/DataContractAttributeEnumTypeConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/DataMemberAttributeEdmPropertyConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/DataMemberAttributeEdmPropertyConvention.cs
index 2269869685..3487b75f43 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/DataMemberAttributeEdmPropertyConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/DataMemberAttributeEdmPropertyConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Linq;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/DefaultValueAttributeEdmPropertyConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/DefaultValueAttributeEdmPropertyConvention.cs
index 17c17378a7..7ff0c6b15c 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/DefaultValueAttributeEdmPropertyConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/DefaultValueAttributeEdmPropertyConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.ComponentModel;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/DerivedTypeConstraintAttributeEdmPropertyConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/DerivedTypeConstraintAttributeEdmPropertyConvention.cs
index bbdcec7a4e..f93ac0b052 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/DerivedTypeConstraintAttributeEdmPropertyConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/DerivedTypeConstraintAttributeEdmPropertyConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/ExpandAttributeEdmPropertyConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/ExpandAttributeEdmPropertyConvention.cs
index 427fdb04a9..3e46aceecd 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/ExpandAttributeEdmPropertyConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/ExpandAttributeEdmPropertyConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/ExpandAttributeEdmTypeConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/ExpandAttributeEdmTypeConvention.cs
index 29d4816340..7852714d0e 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/ExpandAttributeEdmTypeConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/ExpandAttributeEdmTypeConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/FilterAttributeEdmPropertyConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/FilterAttributeEdmPropertyConvention.cs
index ad67cdc41f..9221e9703a 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/FilterAttributeEdmPropertyConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/FilterAttributeEdmPropertyConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/FilterAttributeEdmTypeConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/FilterAttributeEdmTypeConvention.cs
index 54a28c2fee..62d4921d52 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/FilterAttributeEdmTypeConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/FilterAttributeEdmTypeConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/ForeignKeyAttributeConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/ForeignKeyAttributeConvention.cs
index 7ded2e39f4..8b0384ea8f 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/ForeignKeyAttributeConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/ForeignKeyAttributeConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/IgnoreDataMemberAttributeEdmPropertyConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/IgnoreDataMemberAttributeEdmPropertyConvention.cs
index 21e9a6db85..5b75c5caf1 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/IgnoreDataMemberAttributeEdmPropertyConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/IgnoreDataMemberAttributeEdmPropertyConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Linq;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/KeyAttributeEdmPropertyConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/KeyAttributeEdmPropertyConvention.cs
index 745c1e6f7d..84bd20023e 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/KeyAttributeEdmPropertyConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/KeyAttributeEdmPropertyConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.ComponentModel.DataAnnotations;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/MaxLengthAttributeEdmPropertyConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/MaxLengthAttributeEdmPropertyConvention.cs
index d897a1624b..d230e4a42d 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/MaxLengthAttributeEdmPropertyConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/MaxLengthAttributeEdmPropertyConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.ComponentModel.DataAnnotations;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/MediaTypeAttributeConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/MediaTypeAttributeConvention.cs
index 31027691bd..c16a16cf80 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/MediaTypeAttributeConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/MediaTypeAttributeConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/NonFilterableAttributeEdmPropertyConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/NonFilterableAttributeEdmPropertyConvention.cs
index 5a891bca42..638aa3a5cb 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/NonFilterableAttributeEdmPropertyConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/NonFilterableAttributeEdmPropertyConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/NotCountableAttributeEdmPropertyConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/NotCountableAttributeEdmPropertyConvention.cs
index 5c6d6816e0..18b66d6345 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/NotCountableAttributeEdmPropertyConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/NotCountableAttributeEdmPropertyConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Common;
@@ -30,4 +34,4 @@ public override void Apply(PropertyConfiguration edmProperty,
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/NotExpandableAttributeEdmPropertyConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/NotExpandableAttributeEdmPropertyConvention.cs
index 920574c34f..7f070bfae3 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/NotExpandableAttributeEdmPropertyConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/NotExpandableAttributeEdmPropertyConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/NotFilterableAttributeEdmPropertyConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/NotFilterableAttributeEdmPropertyConvention.cs
index cdf5d32d91..2c1ef42914 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/NotFilterableAttributeEdmPropertyConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/NotFilterableAttributeEdmPropertyConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/NotMappedAttributeEdmPropertyConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/NotMappedAttributeEdmPropertyConvention.cs
index 2b2b189107..46198d2ec0 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/NotMappedAttributeEdmPropertyConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/NotMappedAttributeEdmPropertyConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/NotNavigableAttributeEdmPropertyConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/NotNavigableAttributeEdmPropertyConvention.cs
index e972a1d967..e98bda77f7 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/NotNavigableAttributeEdmPropertyConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/NotNavigableAttributeEdmPropertyConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/NotSortableAttributeEdmPropertyConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/NotSortableAttributeEdmPropertyConvention.cs
index e4c03230a8..bbd6be210f 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/NotSortableAttributeEdmPropertyConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/NotSortableAttributeEdmPropertyConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/OrderByAttributeEdmPropertyConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/OrderByAttributeEdmPropertyConvention.cs
index a50e02da01..0bce099695 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/OrderByAttributeEdmPropertyConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/OrderByAttributeEdmPropertyConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/OrderByAttributeEdmTypeConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/OrderByAttributeEdmTypeConvention.cs
index f508456c41..2d447635f8 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/OrderByAttributeEdmTypeConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/OrderByAttributeEdmTypeConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/PageAttributeEdmPropertyConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/PageAttributeEdmPropertyConvention.cs
index 6952ee8e43..b8c4cb7538 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/PageAttributeEdmPropertyConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/PageAttributeEdmPropertyConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/PageAttributeEdmTypeConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/PageAttributeEdmTypeConvention.cs
index d6e7523aa8..61f174db57 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/PageAttributeEdmTypeConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/PageAttributeEdmTypeConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/RequiredAttributeEdmPropertyConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/RequiredAttributeEdmPropertyConvention.cs
index dfc86ccefb..6637ccdee1 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/RequiredAttributeEdmPropertyConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/RequiredAttributeEdmPropertyConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.ComponentModel.DataAnnotations;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/SelectAttributeEdmPropertyConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/SelectAttributeEdmPropertyConvention.cs
index 6115b08af7..33279c206b 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/SelectAttributeEdmPropertyConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/SelectAttributeEdmPropertyConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/SelectAttributeEdmTypeConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/SelectAttributeEdmTypeConvention.cs
index 7a4a7427f4..1eb446275f 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/SelectAttributeEdmTypeConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/SelectAttributeEdmTypeConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/TimestampAttributeEdmPropertyConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/TimestampAttributeEdmPropertyConvention.cs
index 044e64c10b..1d07b95c2e 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/TimestampAttributeEdmPropertyConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/TimestampAttributeEdmPropertyConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/UnsortableAttributeEdmPropertyConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/UnsortableAttributeEdmPropertyConvention.cs
index e077686aab..7190b7276c 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/UnsortableAttributeEdmPropertyConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/Attributes/UnsortableAttributeEdmPropertyConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/ConventionsHelpers.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/ConventionsHelpers.cs
index 21a4194424..a67090b7ab 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/ConventionsHelpers.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/ConventionsHelpers.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/EntityKeyConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/EntityKeyConvention.cs
index 14703f3010..8d28e64676 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/EntityKeyConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/EntityKeyConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/EntityTypeConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/EntityTypeConvention.cs
index 0188c81e3b..a00db3b6ab 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/EntityTypeConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/EntityTypeConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
namespace Microsoft.AspNet.OData.Builder.Conventions
{
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/ForeignKeyDiscoveryConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/ForeignKeyDiscoveryConvention.cs
index 3eabb7bd73..a6d9ced2fd 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/ForeignKeyDiscoveryConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/ForeignKeyDiscoveryConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/FunctionLinkGenerationConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/FunctionLinkGenerationConvention.cs
index e16e04376f..13faabccad 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/FunctionLinkGenerationConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/FunctionLinkGenerationConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Linq;
using Microsoft.OData.Edm;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/IConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/IConvention.cs
index a4788afb54..b34e0cd979 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/IConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/IConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Diagnostics.CodeAnalysis;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/IEdmPropertyConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/IEdmPropertyConvention.cs
index 8b8c69b526..f5602d9f83 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/IEdmPropertyConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/IEdmPropertyConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
namespace Microsoft.AspNet.OData.Builder.Conventions
{
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/IEdmPropertyConventionOfTPropertyConfiguration.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/IEdmPropertyConventionOfTPropertyConfiguration.cs
index 7072c3bf97..ca6dadece7 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/IEdmPropertyConventionOfTPropertyConfiguration.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/IEdmPropertyConventionOfTPropertyConfiguration.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
namespace Microsoft.AspNet.OData.Builder.Conventions
{
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/IEdmTypeConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/IEdmTypeConvention.cs
index c5ff8cf56a..ffa0e51841 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/IEdmTypeConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/IEdmTypeConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
namespace Microsoft.AspNet.OData.Builder.Conventions
{
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/INavigationSourceConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/INavigationSourceConvention.cs
index b94728f57f..027c04b4a0 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/INavigationSourceConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/INavigationSourceConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
namespace Microsoft.AspNet.OData.Builder.Conventions
{
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/IOperationConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/IOperationConvention.cs
index 4a7aa0ad7e..8cb7fcc498 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/IOperationConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/IOperationConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
namespace Microsoft.AspNet.OData.Builder.Conventions
{
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/NavigationLinksGenerationConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/NavigationLinksGenerationConvention.cs
index ea6a56d03e..d1d34ab8b8 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/NavigationLinksGenerationConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/NavigationLinksGenerationConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/SelfLinksGenerationConvention.cs b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/SelfLinksGenerationConvention.cs
index 2ba44eea76..4bb62b74cb 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/SelfLinksGenerationConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/Conventions/SelfLinksGenerationConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Linq;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/DecimalPropertyConfiguration.cs b/src/Microsoft.AspNet.OData.Shared/Builder/DecimalPropertyConfiguration.cs
index e271844535..23bc7a2647 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/DecimalPropertyConfiguration.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/DecimalPropertyConfiguration.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Reflection;
@@ -26,4 +30,4 @@ public DecimalPropertyConfiguration(PropertyInfo property, StructuralTypeConfigu
///
public int? Scale { get; set; }
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/DerivedTypeConstraintAttribute.cs b/src/Microsoft.AspNet.OData.Shared/Builder/DerivedTypeConstraintAttribute.cs
index f24a5ebb6b..62da93cb78 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/DerivedTypeConstraintAttribute.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/DerivedTypeConstraintAttribute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Common;
using System;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/DerivedTypeConstraintConfiguration.cs b/src/Microsoft.AspNet.OData.Shared/Builder/DerivedTypeConstraintConfiguration.cs
index ae0a6bd410..a892e1c2e0 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/DerivedTypeConstraintConfiguration.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/DerivedTypeConstraintConfiguration.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/DynamicPropertyDictionaryAnnotation.cs b/src/Microsoft.AspNet.OData.Shared/Builder/DynamicPropertyDictionaryAnnotation.cs
index 5daafd88f8..cc1e566606 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/DynamicPropertyDictionaryAnnotation.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/DynamicPropertyDictionaryAnnotation.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Reflection;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/EdmModelHelperMethods.cs b/src/Microsoft.AspNet.OData.Shared/Builder/EdmModelHelperMethods.cs
index a161d93110..8337a6faa2 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/EdmModelHelperMethods.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/EdmModelHelperMethods.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/EdmTypeBuilder.cs b/src/Microsoft.AspNet.OData.Shared/Builder/EdmTypeBuilder.cs
index af528225fd..c07c04b857 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/EdmTypeBuilder.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/EdmTypeBuilder.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
@@ -18,7 +22,7 @@ namespace Microsoft.AspNet.OData.Builder
///
/// builds 's from 's.
///
- [SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling", Justification = "Class coupling acceptable")]
+ [SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling", Justification = "Class coupling acceptable")]
internal class EdmTypeBuilder
{
private readonly List _configurations;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/EdmTypeConfigurationExtensions.cs b/src/Microsoft.AspNet.OData.Shared/Builder/EdmTypeConfigurationExtensions.cs
index ab05bf4d82..80607330e6 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/EdmTypeConfigurationExtensions.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/EdmTypeConfigurationExtensions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Diagnostics.Contracts;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/EdmTypeMap.cs b/src/Microsoft.AspNet.OData.Shared/Builder/EdmTypeMap.cs
index 92b3cf705a..e25af27610 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/EdmTypeMap.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/EdmTypeMap.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/EntityCollectionConfigurationOfTEntityType.cs b/src/Microsoft.AspNet.OData.Shared/Builder/EntityCollectionConfigurationOfTEntityType.cs
index 0759c821ff..191bdf3e31 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/EntityCollectionConfigurationOfTEntityType.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/EntityCollectionConfigurationOfTEntityType.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Diagnostics.Contracts;
@@ -44,4 +48,4 @@ public FunctionConfiguration Function(string name)
return configuration;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/EntitySetConfiguration.cs b/src/Microsoft.AspNet.OData.Shared/Builder/EntitySetConfiguration.cs
index e79faa5c35..11c3e49c69 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/EntitySetConfiguration.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/EntitySetConfiguration.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Diagnostics.CodeAnalysis;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/EntitySetConfigurationOfTEntityType.cs b/src/Microsoft.AspNet.OData.Shared/Builder/EntitySetConfigurationOfTEntityType.cs
index a2c91ee1e6..926093960a 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/EntitySetConfigurationOfTEntityType.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/EntitySetConfigurationOfTEntityType.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/EntityTypeConfiguration.cs b/src/Microsoft.AspNet.OData.Shared/Builder/EntityTypeConfiguration.cs
index 4caef94c0d..0f34918c2b 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/EntityTypeConfiguration.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/EntityTypeConfiguration.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/EntityTypeConfigurationOfTEntityType.cs b/src/Microsoft.AspNet.OData.Shared/Builder/EntityTypeConfigurationOfTEntityType.cs
index e6cd007f9c..fcf3492c55 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/EntityTypeConfigurationOfTEntityType.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/EntityTypeConfigurationOfTEntityType.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/EnumMemberConfiguration.cs b/src/Microsoft.AspNet.OData.Shared/Builder/EnumMemberConfiguration.cs
index c9509c0098..6d8e10b870 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/EnumMemberConfiguration.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/EnumMemberConfiguration.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Diagnostics.Contracts;
@@ -75,4 +79,4 @@ public string Name
/// The default value is true
public bool AddedExplicitly { get; set; }
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/EnumPropertyConfiguration.cs b/src/Microsoft.AspNet.OData.Shared/Builder/EnumPropertyConfiguration.cs
index 0ed2eba4ff..e4cb9fd992 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/EnumPropertyConfiguration.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/EnumPropertyConfiguration.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Reflection;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/EnumTypeConfiguration.cs b/src/Microsoft.AspNet.OData.Shared/Builder/EnumTypeConfiguration.cs
index 48279da3d9..f31ff1661a 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/EnumTypeConfiguration.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/EnumTypeConfiguration.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/EnumTypeConfigurationOfTEnumType.cs b/src/Microsoft.AspNet.OData.Shared/Builder/EnumTypeConfigurationOfTEnumType.cs
index 881b392b66..14520d30be 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/EnumTypeConfigurationOfTEnumType.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/EnumTypeConfigurationOfTEnumType.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
@@ -93,4 +97,4 @@ public EnumMemberConfiguration Member(TEnumType enumMember)
return _configuration.AddMember((Enum)(object)enumMember);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/FunctionConfiguration.cs b/src/Microsoft.AspNet.OData.Shared/Builder/FunctionConfiguration.cs
index 382895585c..ca6489e696 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/FunctionConfiguration.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/FunctionConfiguration.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Diagnostics.CodeAnalysis;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/IEdmTypeConfiguration.cs b/src/Microsoft.AspNet.OData.Shared/Builder/IEdmTypeConfiguration.cs
index 7f76ce1bec..ec53f655e9 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/IEdmTypeConfiguration.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/IEdmTypeConfiguration.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Diagnostics.CodeAnalysis;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/IODataInstanceAnnotationContainer.cs b/src/Microsoft.AspNet.OData.Shared/Builder/IODataInstanceAnnotationContainer.cs
index b6118ac630..619e1023b5 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/IODataInstanceAnnotationContainer.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/IODataInstanceAnnotationContainer.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/InstanceAnnotationContainerAnnotation.cs b/src/Microsoft.AspNet.OData.Shared/Builder/InstanceAnnotationContainerAnnotation.cs
index 87638c87e5..4ec2cd4199 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/InstanceAnnotationContainerAnnotation.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/InstanceAnnotationContainerAnnotation.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Reflection;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/LengthPropertyConfiguration.cs b/src/Microsoft.AspNet.OData.Shared/Builder/LengthPropertyConfiguration.cs
index 2e646468a8..668f9778da 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/LengthPropertyConfiguration.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/LengthPropertyConfiguration.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Reflection;
@@ -26,4 +30,4 @@ public LengthPropertyConfiguration(PropertyInfo property, StructuralTypeConfigur
///
public int? MaxLength { get; set; }
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/LinkGenerationHelpers.cs b/src/Microsoft.AspNet.OData.Shared/Builder/LinkGenerationHelpers.cs
index 07deb35170..c4d4b109e9 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/LinkGenerationHelpers.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/LinkGenerationHelpers.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/LowerCamelCaser.cs b/src/Microsoft.AspNet.OData.Shared/Builder/LowerCamelCaser.cs
index 9bd1b4ed96..cd34c71c72 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/LowerCamelCaser.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/LowerCamelCaser.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Diagnostics.CodeAnalysis;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/MediaTypeAttribute.cs b/src/Microsoft.AspNet.OData.Shared/Builder/MediaTypeAttribute.cs
index fb91b33f31..bf54a33b8b 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/MediaTypeAttribute.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/MediaTypeAttribute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/NameResolverOptions.cs b/src/Microsoft.AspNet.OData.Shared/Builder/NameResolverOptions.cs
index 41305f8d82..16cfec6128 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/NameResolverOptions.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/NameResolverOptions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/NavigationLinkBuilder.cs b/src/Microsoft.AspNet.OData.Shared/Builder/NavigationLinkBuilder.cs
index 1b125e48e1..e53409cf1d 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/NavigationLinkBuilder.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/NavigationLinkBuilder.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/NavigationPropertyBindingConfiguration.cs b/src/Microsoft.AspNet.OData.Shared/Builder/NavigationPropertyBindingConfiguration.cs
index 0124591ea7..467ddc2291 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/NavigationPropertyBindingConfiguration.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/NavigationPropertyBindingConfiguration.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Reflection;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/NavigationPropertyBindingOption.cs b/src/Microsoft.AspNet.OData.Shared/Builder/NavigationPropertyBindingOption.cs
index 3962997cd2..5aec0bfdea 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/NavigationPropertyBindingOption.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/NavigationPropertyBindingOption.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
namespace Microsoft.AspNet.OData.Builder
{
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/NavigationPropertyConfiguration.cs b/src/Microsoft.AspNet.OData.Shared/Builder/NavigationPropertyConfiguration.cs
index 415cc6f8ea..60173b5d27 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/NavigationPropertyConfiguration.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/NavigationPropertyConfiguration.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/NavigationPropertyExtensions.cs b/src/Microsoft.AspNet.OData.Shared/Builder/NavigationPropertyExtensions.cs
index 2c26940630..3595351699 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/NavigationPropertyExtensions.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/NavigationPropertyExtensions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/NavigationSourceAndAnnotations.cs b/src/Microsoft.AspNet.OData.Shared/Builder/NavigationSourceAndAnnotations.cs
index 56873ba6bf..caec384501 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/NavigationSourceAndAnnotations.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/NavigationSourceAndAnnotations.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.OData.Edm;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/NavigationSourceConfiguration.cs b/src/Microsoft.AspNet.OData.Shared/Builder/NavigationSourceConfiguration.cs
index 8dc530a2d2..5cdfbcc39d 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/NavigationSourceConfiguration.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/NavigationSourceConfiguration.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/NavigationSourceConfigurationOfTEntityType.cs b/src/Microsoft.AspNet.OData.Shared/Builder/NavigationSourceConfigurationOfTEntityType.cs
index 98cc80bc09..41fb480b8f 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/NavigationSourceConfigurationOfTEntityType.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/NavigationSourceConfigurationOfTEntityType.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/NavigationSourceLinkBuilderAnnotation.cs b/src/Microsoft.AspNet.OData.Shared/Builder/NavigationSourceLinkBuilderAnnotation.cs
index b2f4ed9319..f65834550b 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/NavigationSourceLinkBuilderAnnotation.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/NavigationSourceLinkBuilderAnnotation.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/NavigationSourceUrlAnnotation.cs b/src/Microsoft.AspNet.OData.Shared/Builder/NavigationSourceUrlAnnotation.cs
index 14e9190096..5631d3a3cc 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/NavigationSourceUrlAnnotation.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/NavigationSourceUrlAnnotation.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
namespace Microsoft.AspNet.OData.Builder
{
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/NonBindingParameterConfiguration.cs b/src/Microsoft.AspNet.OData.Shared/Builder/NonBindingParameterConfiguration.cs
index 30a315985e..d84be338e0 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/NonBindingParameterConfiguration.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/NonBindingParameterConfiguration.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
namespace Microsoft.AspNet.OData.Builder
{
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/NullableEnumTypeConfiguration.cs b/src/Microsoft.AspNet.OData.Shared/Builder/NullableEnumTypeConfiguration.cs
index 74c0285163..b86b5a3efa 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/NullableEnumTypeConfiguration.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/NullableEnumTypeConfiguration.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Diagnostics.CodeAnalysis;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/ODataConventionModelBuilder.cs b/src/Microsoft.AspNet.OData.Shared/Builder/ODataConventionModelBuilder.cs
index 2d8d2a0d65..ff65fa77d1 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/ODataConventionModelBuilder.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/ODataConventionModelBuilder.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/ODataConventionModelBuilderExtensions.cs b/src/Microsoft.AspNet.OData.Shared/Builder/ODataConventionModelBuilderExtensions.cs
index 154cd790ce..49cfc39c33 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/ODataConventionModelBuilderExtensions.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/ODataConventionModelBuilderExtensions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.ComponentModel;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/ODataInstanceAnnotationContainer.cs b/src/Microsoft.AspNet.OData.Shared/Builder/ODataInstanceAnnotationContainer.cs
index 7c74c8057e..7b57e51dab 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/ODataInstanceAnnotationContainer.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/ODataInstanceAnnotationContainer.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/ODataModelBuilder.cs b/src/Microsoft.AspNet.OData.Shared/Builder/ODataModelBuilder.cs
index 7a8244d481..fe30942e0d 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/ODataModelBuilder.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/ODataModelBuilder.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/OperationConfiguration.cs b/src/Microsoft.AspNet.OData.Shared/Builder/OperationConfiguration.cs
index 59e7f564c7..10cd67f2e2 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/OperationConfiguration.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/OperationConfiguration.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/OperationKind.cs b/src/Microsoft.AspNet.OData.Shared/Builder/OperationKind.cs
index 89ff963425..0f9f597ada 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/OperationKind.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/OperationKind.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
namespace Microsoft.AspNet.OData.Builder
{
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/OperationLinkBuilder.cs b/src/Microsoft.AspNet.OData.Shared/Builder/OperationLinkBuilder.cs
index 9f72f40c12..5702ea306e 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/OperationLinkBuilder.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/OperationLinkBuilder.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/OperationTitleAnnotation.cs b/src/Microsoft.AspNet.OData.Shared/Builder/OperationTitleAnnotation.cs
index c2638dbc17..b87082534f 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/OperationTitleAnnotation.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/OperationTitleAnnotation.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
namespace Microsoft.AspNet.OData.Builder
{
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/ParameterConfiguration.cs b/src/Microsoft.AspNet.OData.Shared/Builder/ParameterConfiguration.cs
index 0a37702edd..9cdd4828cf 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/ParameterConfiguration.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/ParameterConfiguration.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/PrecisionPropertyConfiguration.cs b/src/Microsoft.AspNet.OData.Shared/Builder/PrecisionPropertyConfiguration.cs
index 0a68dc143f..d6981a02da 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/PrecisionPropertyConfiguration.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/PrecisionPropertyConfiguration.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Reflection;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/PrimitivePropertyConfiguration.cs b/src/Microsoft.AspNet.OData.Shared/Builder/PrimitivePropertyConfiguration.cs
index ae3562f249..71d16dc2bd 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/PrimitivePropertyConfiguration.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/PrimitivePropertyConfiguration.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Reflection;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/PrimitivePropertyConfigurationExtensions.cs b/src/Microsoft.AspNet.OData.Shared/Builder/PrimitivePropertyConfigurationExtensions.cs
index 300a3dba9d..ca10ece232 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/PrimitivePropertyConfigurationExtensions.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/PrimitivePropertyConfigurationExtensions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Common;
using Microsoft.OData.Edm;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/PrimitiveTypeConfiguration.cs b/src/Microsoft.AspNet.OData.Shared/Builder/PrimitiveTypeConfiguration.cs
index 7d6124e8c0..37f7f0258b 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/PrimitiveTypeConfiguration.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/PrimitiveTypeConfiguration.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/PropertyConfiguration.cs b/src/Microsoft.AspNet.OData.Shared/Builder/PropertyConfiguration.cs
index caf9667fb0..d266cfd6f3 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/PropertyConfiguration.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/PropertyConfiguration.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/PropertyKind.cs b/src/Microsoft.AspNet.OData.Shared/Builder/PropertyKind.cs
index 5fe6aeaad7..fe8455c47d 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/PropertyKind.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/PropertyKind.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
namespace Microsoft.AspNet.OData.Builder
{
@@ -44,4 +48,3 @@ public enum PropertyKind
InstanceAnnotations = 6
}
}
-
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/PropertyPairSelectorVisitor.cs b/src/Microsoft.AspNet.OData.Shared/Builder/PropertyPairSelectorVisitor.cs
index ae1d2520db..b69008487f 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/PropertyPairSelectorVisitor.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/PropertyPairSelectorVisitor.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/PropertySelectorVisitor.cs b/src/Microsoft.AspNet.OData.Shared/Builder/PropertySelectorVisitor.cs
index 25896a8ab7..b1f4f9f187 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/PropertySelectorVisitor.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/PropertySelectorVisitor.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/QueryConfiguration.cs b/src/Microsoft.AspNet.OData.Shared/Builder/QueryConfiguration.cs
index cd25f01f6e..9892c26d47 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/QueryConfiguration.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/QueryConfiguration.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using Microsoft.AspNet.OData.Query;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/ReturnedEntitySetAnnotation.cs b/src/Microsoft.AspNet.OData.Shared/Builder/ReturnedEntitySetAnnotation.cs
index 1d715b7b62..1dbab004e7 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/ReturnedEntitySetAnnotation.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/ReturnedEntitySetAnnotation.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/SelfLinkBuilder.cs b/src/Microsoft.AspNet.OData.Shared/Builder/SelfLinkBuilder.cs
index b5311e5e5e..13ff4a0c42 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/SelfLinkBuilder.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/SelfLinkBuilder.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/SingletonAttribute.cs b/src/Microsoft.AspNet.OData.Shared/Builder/SingletonAttribute.cs
index 2b741d8931..10a47228ae 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/SingletonAttribute.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/SingletonAttribute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/SingletonConfiguration.cs b/src/Microsoft.AspNet.OData.Shared/Builder/SingletonConfiguration.cs
index 77f82ed69a..1021b97532 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/SingletonConfiguration.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/SingletonConfiguration.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/SingletonConfigurationOfTEntityType.cs b/src/Microsoft.AspNet.OData.Shared/Builder/SingletonConfigurationOfTEntityType.cs
index 990e8a63e7..2105e83a76 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/SingletonConfigurationOfTEntityType.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/SingletonConfigurationOfTEntityType.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.OData.Edm;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/StructuralPropertyConfiguration.cs b/src/Microsoft.AspNet.OData.Shared/Builder/StructuralPropertyConfiguration.cs
index f31d7a13b9..245c29cbd1 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/StructuralPropertyConfiguration.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/StructuralPropertyConfiguration.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Reflection;
using Microsoft.AspNet.OData.Formatter;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/StructuralTypeConfiguration.cs b/src/Microsoft.AspNet.OData.Shared/Builder/StructuralTypeConfiguration.cs
index e8bb0609a8..92ae38c776 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/StructuralTypeConfiguration.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/StructuralTypeConfiguration.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/StructuralTypeConfigurationOfTStructuralType.cs b/src/Microsoft.AspNet.OData.Shared/Builder/StructuralTypeConfigurationOfTStructuralType.cs
index e56ecf369d..85004b50e8 100644
--- a/src/Microsoft.AspNet.OData.Shared/Builder/StructuralTypeConfigurationOfTStructuralType.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Builder/StructuralTypeConfigurationOfTStructuralType.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections;
diff --git a/src/Microsoft.AspNet.OData.Shared/ClrEnumMemberAnnotation.cs b/src/Microsoft.AspNet.OData.Shared/ClrEnumMemberAnnotation.cs
index c5d7454463..79fa25168b 100644
--- a/src/Microsoft.AspNet.OData.Shared/ClrEnumMemberAnnotation.cs
+++ b/src/Microsoft.AspNet.OData.Shared/ClrEnumMemberAnnotation.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/ClrPropertyInfoAnnotation.cs b/src/Microsoft.AspNet.OData.Shared/ClrPropertyInfoAnnotation.cs
index 51dfc22ae7..d3440898da 100644
--- a/src/Microsoft.AspNet.OData.Shared/ClrPropertyInfoAnnotation.cs
+++ b/src/Microsoft.AspNet.OData.Shared/ClrPropertyInfoAnnotation.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Reflection;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/ClrTypeAnnotation.cs b/src/Microsoft.AspNet.OData.Shared/ClrTypeAnnotation.cs
index f41bd4b1a7..3ce6a0050c 100644
--- a/src/Microsoft.AspNet.OData.Shared/ClrTypeAnnotation.cs
+++ b/src/Microsoft.AspNet.OData.Shared/ClrTypeAnnotation.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.OData.Edm;
diff --git a/src/Microsoft.AspNet.OData.Shared/Common/CollectionExtensions.cs b/src/Microsoft.AspNet.OData.Shared/Common/CollectionExtensions.cs
index b81e25ee92..72b17ab4f4 100644
--- a/src/Microsoft.AspNet.OData.Shared/Common/CollectionExtensions.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Common/CollectionExtensions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Common/CommonWebApiResources.Designer.cs b/src/Microsoft.AspNet.OData.Shared/Common/CommonWebApiResources.Designer.cs
index c55047b47f..fb9e223fff 100644
--- a/src/Microsoft.AspNet.OData.Shared/Common/CommonWebApiResources.Designer.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Common/CommonWebApiResources.Designer.cs
@@ -1,4 +1,4 @@
-//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
//
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
diff --git a/src/Microsoft.AspNet.OData.Shared/Common/Error.cs b/src/Microsoft.AspNet.OData.Shared/Common/Error.cs
index 004c0178ed..8d6e2f6aa1 100644
--- a/src/Microsoft.AspNet.OData.Shared/Common/Error.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Common/Error.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
@@ -99,6 +103,7 @@ internal static ArgumentNullException PropertyNull()
/// Creates an with a default message.
///
/// The logged .
+ [SuppressMessage("Microsoft.Usage", "CA2208:InstantiateArgumentExceptionsCorrectly")]
internal static ArgumentException PropertyNullOrWhiteSpace()
{
return new ArgumentException(CommonWebApiResources.PropertyNullOrWhiteSpace, "value");
diff --git a/src/Microsoft.AspNet.OData.Shared/Common/ListWrapperCollection.cs b/src/Microsoft.AspNet.OData.Shared/Common/ListWrapperCollection.cs
index 16fba86adf..144f22c55a 100644
--- a/src/Microsoft.AspNet.OData.Shared/Common/ListWrapperCollection.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Common/ListWrapperCollection.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Collections.ObjectModel;
diff --git a/src/Microsoft.AspNet.OData.Shared/Common/PropertyHelper.cs b/src/Microsoft.AspNet.OData.Shared/Common/PropertyHelper.cs
index 5dd6b41ac1..3e8d784a36 100644
--- a/src/Microsoft.AspNet.OData.Shared/Common/PropertyHelper.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Common/PropertyHelper.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Concurrent;
diff --git a/src/Microsoft.AspNet.OData.Shared/Common/SRResources.Designer.cs b/src/Microsoft.AspNet.OData.Shared/Common/SRResources.Designer.cs
index 3c53dad32a..44270bb897 100644
--- a/src/Microsoft.AspNet.OData.Shared/Common/SRResources.Designer.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Common/SRResources.Designer.cs
@@ -1,4 +1,4 @@
-//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
//
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
@@ -498,6 +498,17 @@ internal static string CantFindEdmType
}
}
+ ///
+ /// Looks up a localized string similar to Cannot use Changed Object of type '{0}' on an entity of type '{1}'..
+ ///
+ internal static string ChangedObjectTypeMismatch
+ {
+ get
+ {
+ return ResourceManager.GetString("ChangedObjectTypeMismatch", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to The given model does not contain the type '{0}'..
///
@@ -564,6 +575,17 @@ internal static string CollectionShouldHaveClearMethod
}
}
+ ///
+ /// Looks up a localized string similar to ContentID.
+ ///
+ internal static string ContentID
+ {
+ get
+ {
+ return ResourceManager.GetString("ContentID", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Type {0} already added as derived type constraint.
///
@@ -597,6 +619,17 @@ internal static string CreateODataValueNotSupported
}
}
+ ///
+ /// Looks up a localized string similar to the error DataModificationException
+ ///
+ internal static string DataModificationException
+ {
+ get
+ {
+ return ResourceManager.GetString("DataModificationException", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to The actual entity type '{0}' is not assignable to the expected type '{1}'..
///
@@ -608,6 +641,17 @@ internal static string DeltaEntityTypeNotAssignable
}
}
+ ///
+ /// Looks up a localized string similar to The actual error DeltaLinkNotSupported
+ ///
+ internal static string DeltaLinkNotSupported
+ {
+ get
+ {
+ return ResourceManager.GetString("DeltaLinkNotSupported", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Cannot find nested resource name '{0}' in parent resource type '{1}'.
///
@@ -2721,6 +2765,28 @@ internal static string RequestUriTooShortForODataPath
}
}
+ ///
+ /// Looks up a localized string similar to Cannot find the resource type '{0}' in the model..
+ ///
+ internal static string ResourcesShouldbePresent
+ {
+ get
+ {
+ return ResourceManager.GetString("ResourcesShouldbePresent", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Cannot find the resource wrapper type '{0}' in the model..
+ ///
+ internal static string ResourceSetWrapperSupported
+ {
+ get
+ {
+ return ResourceManager.GetString("ResourceSetWrapperSupported", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Cannot find the resource type '{0}' in the model..
///
diff --git a/src/Microsoft.AspNet.OData.Shared/Common/SRResources.resx b/src/Microsoft.AspNet.OData.Shared/Common/SRResources.resx
index cfc417253e..270aa879ab 100644
--- a/src/Microsoft.AspNet.OData.Shared/Common/SRResources.resx
+++ b/src/Microsoft.AspNet.OData.Shared/Common/SRResources.resx
@@ -985,4 +985,22 @@
InstanceAnnotation Property name cannot be null or empty.
+
+ ResourceSetWrapper should have ResourceWrappers in it
+
+
+ Can only add ResourceWrapper to ResourceSetWrapper
+
+
+ Cannot use Changed Object of type '{0}' on an entity of type '{1}'.
+
+
+ Core.DataModificationException
+
+
+ Core.ContentID
+
+
+ DeltaLinks are not supported
+
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.OData.Shared/Common/TaskHelpers.cs b/src/Microsoft.AspNet.OData.Shared/Common/TaskHelpers.cs
index c2b34cdcc1..29dcc2e14f 100644
--- a/src/Microsoft.AspNet.OData.Shared/Common/TaskHelpers.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Common/TaskHelpers.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Threading.Tasks;
diff --git a/src/Microsoft.AspNet.OData.Shared/Common/TaskHelpersExtensions.cs b/src/Microsoft.AspNet.OData.Shared/Common/TaskHelpersExtensions.cs
index 544248a510..be032cba9b 100644
--- a/src/Microsoft.AspNet.OData.Shared/Common/TaskHelpersExtensions.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Common/TaskHelpersExtensions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
diff --git a/src/Microsoft.AspNet.OData.Shared/CompatibilityOptions.cs b/src/Microsoft.AspNet.OData.Shared/CompatibilityOptions.cs
index d0044de0d6..75c79df7db 100644
--- a/src/Microsoft.AspNet.OData.Shared/CompatibilityOptions.cs
+++ b/src/Microsoft.AspNet.OData.Shared/CompatibilityOptions.cs
@@ -1,5 +1,10 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
+
using System;
namespace Microsoft.AspNet.OData
diff --git a/src/Microsoft.AspNet.OData.Shared/CompiledPropertyAccessor.cs b/src/Microsoft.AspNet.OData.Shared/CompiledPropertyAccessor.cs
index 4fb8630e50..c805035ec2 100644
--- a/src/Microsoft.AspNet.OData.Shared/CompiledPropertyAccessor.cs
+++ b/src/Microsoft.AspNet.OData.Shared/CompiledPropertyAccessor.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Linq.Expressions;
diff --git a/src/Microsoft.AspNet.OData.Shared/ConcurrencyPropertiesAnnotation.cs b/src/Microsoft.AspNet.OData.Shared/ConcurrencyPropertiesAnnotation.cs
index c41e85c977..2cc18feaa1 100644
--- a/src/Microsoft.AspNet.OData.Shared/ConcurrencyPropertiesAnnotation.cs
+++ b/src/Microsoft.AspNet.OData.Shared/ConcurrencyPropertiesAnnotation.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Concurrent;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/ContentIdHelpers.cs b/src/Microsoft.AspNet.OData.Shared/ContentIdHelpers.cs
index 1ce4054680..d1f98e77ae 100644
--- a/src/Microsoft.AspNet.OData.Shared/ContentIdHelpers.cs
+++ b/src/Microsoft.AspNet.OData.Shared/ContentIdHelpers.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
@@ -83,4 +87,4 @@ private static bool IsContentIdCharacter(char c)
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/CustomAggregateMethodAnnotation.cs b/src/Microsoft.AspNet.OData.Shared/CustomAggregateMethodAnnotation.cs
index e510840e3e..7f4a20b735 100644
--- a/src/Microsoft.AspNet.OData.Shared/CustomAggregateMethodAnnotation.cs
+++ b/src/Microsoft.AspNet.OData.Shared/CustomAggregateMethodAnnotation.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/DataModificationExceptionType.cs b/src/Microsoft.AspNet.OData.Shared/DataModificationExceptionType.cs
new file mode 100644
index 0000000000..6401a9565b
--- /dev/null
+++ b/src/Microsoft.AspNet.OData.Shared/DataModificationExceptionType.cs
@@ -0,0 +1,115 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+
+using System;
+using Microsoft.AspNet.OData.Builder;
+
+namespace Org.OData.Core.V1
+{
+ ///
+ /// Represents a Message Type
+ ///
+ public class MessageType
+ {
+ ///
+ /// Code of message
+ ///
+ public string Code { get; set; }
+
+ ///
+ /// Actual message
+ ///
+ public string Message { get; set; }
+
+ ///
+ /// Severity of message
+ ///
+ public string Severity { get; set; }
+
+ ///
+ /// Target of message
+ ///
+ public string Target { get; set; }
+
+ ///
+ /// Details of message
+ ///
+ public string Details { get; set; }
+ }
+
+ ///
+ /// Represents an Exception Type
+ ///
+ public abstract class ExceptionType
+ {
+ ///
+ /// Represents a MessageType
+ ///
+ public MessageType MessageType { get; set; }
+ }
+
+ ///
+ /// Represents an Exception for Data modification Operation.
+ ///
+ public class DataModificationExceptionType : ExceptionType
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public DataModificationExceptionType(DataModificationOperationKind failedOperation)
+ {
+ this.FailedOperation = failedOperation;
+ }
+
+ ///
+ /// Represents king of type of operation
+ ///
+ public DataModificationOperationKind FailedOperation { get; }
+
+ ///
+ /// Represents response code
+ ///
+ public Int16 ResponseCode { get; set; }
+ }
+
+ ///
+ /// Enumerates the DataModificationOperation for the operation kind
+ ///
+ public enum DataModificationOperationKind
+ {
+ ///
+ /// Insert new Instance
+ ///
+ Insert,
+
+ ///
+ /// Update existing Instance
+ ///
+ Update,
+
+ ///
+ /// Insert new instance or update it if it already exists
+ ///
+ Upsert,
+
+ ///
+ /// Delete existing instance
+ ///
+ Delete,
+
+ ///
+ /// Invoke action or function
+ ///
+ Invoke,
+
+ ///
+ /// Add link between entities
+ ///
+ Link,
+
+ ///
+ /// Remove link between entities
+ ///
+ Unlink
+ }
+}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.OData.Shared/DefaultContainerBuilder.cs b/src/Microsoft.AspNet.OData.Shared/DefaultContainerBuilder.cs
index 3a78c02427..d7c9022fd1 100644
--- a/src/Microsoft.AspNet.OData.Shared/DefaultContainerBuilder.cs
+++ b/src/Microsoft.AspNet.OData.Shared/DefaultContainerBuilder.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Reflection;
diff --git a/src/Microsoft.AspNet.OData.Shared/DefaultEdmPatchMethodHandler.cs b/src/Microsoft.AspNet.OData.Shared/DefaultEdmPatchMethodHandler.cs
new file mode 100644
index 0000000000..8e9390c54d
--- /dev/null
+++ b/src/Microsoft.AspNet.OData.Shared/DefaultEdmPatchMethodHandler.cs
@@ -0,0 +1,161 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.Contracts;
+using System.Linq;
+using Microsoft.OData.Edm;
+
+namespace Microsoft.AspNet.OData
+{
+ ///
+ /// This is the default Patch Handler for non CLR type. This calss has default Get, Create and Update
+ /// and will do these actions. This will be used when the original collection to be Patched is provided.
+ ///
+ internal class DefaultEdmODataAPIHandler : EdmODataAPIHandler
+ {
+ IEdmEntityType entityType;
+ ICollection originalList;
+
+ public DefaultEdmODataAPIHandler(ICollection originalList, IEdmEntityType entityType)
+ {
+ Contract.Assert(entityType != null);
+
+ this.entityType = entityType;
+ this.originalList = originalList?? new List();
+ }
+
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
+ public override ODataAPIResponseStatus TryGet(IDictionary keyValues, out IEdmStructuredObject originalObject, out string errorMessage)
+ {
+ ODataAPIResponseStatus status = ODataAPIResponseStatus.Success;
+ errorMessage = string.Empty;
+ originalObject = null;
+
+ Contract.Assert(keyValues != null);
+
+ try
+ {
+ originalObject = GetFilteredItem(keyValues);
+
+ if (originalObject == null)
+ {
+ status = ODataAPIResponseStatus.NotFound;
+ }
+ }
+ catch (Exception ex)
+ {
+ status = ODataAPIResponseStatus.Failure;
+ errorMessage = ex.Message;
+ }
+
+ return status;
+ }
+
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
+ public override ODataAPIResponseStatus TryCreate(IEdmChangedObject changedObject, out IEdmStructuredObject createdObject, out string errorMessage)
+ {
+ createdObject = null;
+ errorMessage = string.Empty;
+
+ try
+ {
+ createdObject = new EdmEntityObject(entityType);
+ originalList.Add(createdObject);
+
+ return ODataAPIResponseStatus.Success;
+ }
+ catch (Exception ex)
+ {
+ errorMessage = ex.Message;
+
+ return ODataAPIResponseStatus.Failure;
+ }
+ }
+
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
+ public override ODataAPIResponseStatus TryDelete(IDictionary keyValues, out string errorMessage)
+ {
+ errorMessage = string.Empty;
+
+ try
+ {
+ EdmStructuredObject originalObject = GetFilteredItem(keyValues);
+
+ if (originalObject != null)
+ {
+ originalList.Remove(originalObject);
+ }
+
+ return ODataAPIResponseStatus.Success;
+ }
+ catch (Exception ex)
+ {
+ errorMessage = ex.Message;
+
+ return ODataAPIResponseStatus.Failure;
+ }
+ }
+
+ public override EdmODataAPIHandler GetNestedHandler(IEdmStructuredObject parent, string navigationPropertyName)
+ {
+ IEdmNavigationProperty navProperty = entityType.NavigationProperties().FirstOrDefault(navProp => navProp.Name == navigationPropertyName);
+
+ if(navProperty == null)
+ {
+ return null;
+ }
+
+ IEdmEntityType nestedEntityType = navProperty.ToEntityType();
+
+ object obj;
+ if(parent.TryGetPropertyValue(navigationPropertyName, out obj))
+ {
+ ICollection nestedList = obj as ICollection;
+
+ return new DefaultEdmODataAPIHandler(nestedList, nestedEntityType);
+ }
+
+ return null;
+ }
+
+
+ private EdmStructuredObject GetFilteredItem(IDictionary keyValues)
+ {
+ //This logic is for filtering the object based on the set of keys,
+ //There will only be very few key elements usually, mostly 1, so performance wont be impacted.
+
+ if(originalList == null)
+ {
+ return null;
+ }
+
+ foreach (EdmStructuredObject item in originalList)
+ {
+ bool isMatch = true;
+
+ foreach (KeyValuePair keyValue in keyValues)
+ {
+ object value;
+ if (item.TryGetPropertyValue(keyValue.Key, out value))
+ {
+ if (!Equals(value, keyValue.Value))
+ {
+ // Not a match, so try the next one
+ isMatch = false;
+ break;
+ }
+ }
+ }
+
+ if (isMatch)
+ {
+ return item;
+ }
+ }
+
+ return null;
+ }
+ }
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/DefaultODataAPIHandler.cs b/src/Microsoft.AspNet.OData.Shared/DefaultODataAPIHandler.cs
new file mode 100644
index 0000000000..5974ae2169
--- /dev/null
+++ b/src/Microsoft.AspNet.OData.Shared/DefaultODataAPIHandler.cs
@@ -0,0 +1,153 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+
+namespace Microsoft.AspNet.OData
+{
+ ///
+ /// This is the default ODataAPIHandler for CLR type. This calss has default Get, Create and Update
+ /// and will do these actions. This will be used when the original collection to be Patched is provided.
+ ///
+ ///
+ internal class DefaultODataAPIHandler : ODataAPIHandler where TStructuralType :class
+ {
+ Type _clrType;
+ ICollection originalList;
+
+ public DefaultODataAPIHandler(ICollection originalList)
+ {
+ this._clrType = typeof(TStructuralType);
+ this.originalList = originalList?? new List();
+ }
+
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
+ public override ODataAPIResponseStatus TryGet(IDictionary keyValues, out TStructuralType originalObject, out string errorMessage)
+ {
+ ODataAPIResponseStatus status = ODataAPIResponseStatus.Success;
+ errorMessage = string.Empty;
+ originalObject = default(TStructuralType);
+
+ try
+ {
+ originalObject = GetFilteredItem(keyValues);
+
+ if (originalObject == null)
+ {
+ status = ODataAPIResponseStatus.NotFound;
+ }
+ }
+ catch (Exception ex)
+ {
+ status = ODataAPIResponseStatus.Failure;
+ errorMessage = ex.Message;
+ }
+
+ return status;
+ }
+
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
+ public override ODataAPIResponseStatus TryCreate(IDictionary keyValues, out TStructuralType createdObject, out string errorMessage)
+ {
+ createdObject = default(TStructuralType);
+ errorMessage = string.Empty;
+
+ try
+ {
+ if(originalList != null)
+ {
+ originalList = new List();
+ }
+
+ createdObject = Activator.CreateInstance(_clrType) as TStructuralType;
+ originalList.Add(createdObject);
+
+ return ODataAPIResponseStatus.Success;
+ }
+ catch (Exception ex)
+ {
+ errorMessage = ex.Message;
+
+ return ODataAPIResponseStatus.Failure;
+ }
+ }
+
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
+ public override ODataAPIResponseStatus TryDelete(IDictionary keyValues, out string errorMessage)
+ {
+ errorMessage = string.Empty;
+
+ try
+ {
+ TStructuralType originalObject = GetFilteredItem(keyValues);
+ originalList.Remove(originalObject);
+
+ return ODataAPIResponseStatus.Success;
+ }
+ catch (Exception ex)
+ {
+ errorMessage = ex.Message;
+
+ return ODataAPIResponseStatus.Failure;
+ }
+ }
+
+ public override IODataAPIHandler GetNestedHandler(TStructuralType parent, string navigationPropertyName)
+ {
+ foreach (PropertyInfo property in _clrType.GetProperties())
+ {
+ if (property.Name == navigationPropertyName)
+ {
+ Type type = typeof(DefaultODataAPIHandler<>).MakeGenericType(property.PropertyType.GetGenericArguments()[0]);
+
+ return Activator.CreateInstance(type, property.GetValue(parent)) as IODataAPIHandler;
+ }
+ }
+
+ return null;
+ }
+
+
+ private TStructuralType GetFilteredItem(IDictionary keyValues)
+ {
+ //This logic is for filtering the object based on the set of keys,
+ //There will only be very few key elements usually, mostly 1, so performance wont be impacted.
+
+ if(originalList == null || originalList.Count == 0)
+ {
+ return default(TStructuralType);
+ }
+
+ Dictionary propertyInfos = new Dictionary();
+
+ foreach (string key in keyValues.Keys)
+ {
+ propertyInfos.Add(key, _clrType.GetProperty(key));
+ }
+
+ foreach (TStructuralType item in originalList)
+ {
+ bool isMatch = true;
+
+ foreach (KeyValuePair keyValue in keyValues)
+ {
+ if (!Equals(propertyInfos[keyValue.Key].GetValue(item), keyValue.Value))
+ {
+ // Not a match, so try the next one
+ isMatch = false;
+ break;
+ }
+ }
+
+ if (isMatch)
+ {
+ return item;
+ }
+ }
+
+ return default(TStructuralType);
+ }
+ }
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/Delta.cs b/src/Microsoft.AspNet.OData.Shared/Delta.cs
index 7675def9ae..14cf33e774 100644
--- a/src/Microsoft.AspNet.OData.Shared/Delta.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Delta.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
@@ -95,4 +99,4 @@ public override bool TryGetMember(GetMemberBinder binder, out object result)
///
public abstract IEnumerable GetUnchangedPropertyNames();
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/DeltaDeletedEntityObjectOfT.cs b/src/Microsoft.AspNet.OData.Shared/DeltaDeletedEntityObjectOfT.cs
new file mode 100644
index 0000000000..6a249de90e
--- /dev/null
+++ b/src/Microsoft.AspNet.OData.Shared/DeltaDeletedEntityObjectOfT.cs
@@ -0,0 +1,108 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.Contracts;
+using System.Reflection;
+using System.Threading;
+using Microsoft.AspNet.OData.Builder;
+using Microsoft.AspNet.OData.Common;
+using Microsoft.OData;
+using Microsoft.OData.Edm;
+
+namespace Microsoft.AspNet.OData
+{
+ ///
+ /// Represents an with a backing CLR .
+ /// Used to hold the Deleted Entry object in the Delta Feed Payload.
+ ///
+ [NonValidatingParameterBinding]
+ public class DeltaDeletedEntityObject : Delta, IDeltaDeletedEntityObject where TStructuralType : class
+ {
+ ///
+ /// Initializes a new instance of .
+ ///
+ public DeltaDeletedEntityObject()
+ : this(typeof(TStructuralType))
+ {
+ }
+
+ ///
+ /// Initializes a new instance of .
+ ///
+ /// The derived entity type or complex type for which the changes would be tracked.
+ /// should be assignable to instances of .
+ ///
+ public DeltaDeletedEntityObject(Type structuralType)
+ : this(structuralType, dynamicDictionaryPropertyInfo: null, instanceAnnotationsPropertyInfo: null)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of .
+ ///
+ /// The derived entity type or complex type for which the changes would be tracked.
+ /// should be assignable to instances of .
+ ///
+ /// Properties to update
+ public DeltaDeletedEntityObject(Type structuralType, IEnumerable updatableProperties)
+ : this(structuralType, updatableProperties, dynamicDictionaryPropertyInfo: null, instanceAnnotationsPropertyInfo: null)
+ {
+
+ }
+
+ ///
+ /// Initializes a new instance of .
+ ///
+ /// The derived entity type or complex type for which the changes would be tracked.
+ /// should be assignable to instances of .
+ ///
+ /// The property info that is used as container for Instance Annotations
+ public DeltaDeletedEntityObject(Type structuralType, PropertyInfo instanceAnnotationsPropertyInfo)
+ : this(structuralType, dynamicDictionaryPropertyInfo: null, instanceAnnotationsPropertyInfo)
+ {
+
+ }
+
+ ///
+ /// Initializes a new instance of .
+ ///
+ /// The derived entity type or complex type for which the changes would be tracked.
+ /// should be assignable to instances of .
+ ///
+ /// The property info that is used as dictionary of dynamic
+ /// properties. null means this entity type is not open.
+ /// The property info that is used as container for Instance Annotations
+ public DeltaDeletedEntityObject(Type structuralType, PropertyInfo dynamicDictionaryPropertyInfo, PropertyInfo instanceAnnotationsPropertyInfo)
+ : this(structuralType, updatableProperties: null , dynamicDictionaryPropertyInfo, instanceAnnotationsPropertyInfo)
+ {
+
+ }
+
+ ///
+ /// Initializes a new instance of .
+ ///
+ /// The derived entity type or complex type for which the changes would be tracked.
+ /// should be assignable to instances of .
+ ///
+ /// Properties that can be updated
+ /// The property info that is used as dictionary of dynamic
+ /// properties. null means this entity type is not open.
+ /// The property info that is used as container for Instance Annotations
+ public DeltaDeletedEntityObject(Type structuralType, IEnumerable updatableProperties, PropertyInfo dynamicDictionaryPropertyInfo, PropertyInfo instanceAnnotationsPropertyInfo)
+ : base(structuralType, updatableProperties, dynamicDictionaryPropertyInfo, instanceAnnotationsPropertyInfo)
+ {
+ DeltaKind = EdmDeltaEntityKind.DeletedEntry;
+ }
+
+ ///
+ public Uri Id { get; set; }
+
+ ///
+ public DeltaDeletedEntryReason? Reason { get; set; }
+
+ ///
+ public IEdmNavigationSource NavigationSource { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.OData.Shared/DeltaOfTStructuralType.cs b/src/Microsoft.AspNet.OData.Shared/DeltaOfTStructuralType.cs
index 64c5830fbd..58fa120892 100644
--- a/src/Microsoft.AspNet.OData.Shared/DeltaOfTStructuralType.cs
+++ b/src/Microsoft.AspNet.OData.Shared/DeltaOfTStructuralType.cs
@@ -1,7 +1,12 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
+using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
@@ -10,9 +15,11 @@
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
+using Microsoft.AspNet.OData.Builder;
using Microsoft.AspNet.OData.Builder.Conventions.Attributes;
using Microsoft.AspNet.OData.Common;
using Microsoft.AspNet.OData.Formatter;
+using Microsoft.OData.Edm;
namespace Microsoft.AspNet.OData
{
@@ -21,14 +28,14 @@ namespace Microsoft.AspNet.OData
///
/// TStructuralType is the type of the instance this delta tracks changes for.
[NonValidatingParameterBinding]
- public class Delta : TypedDelta, IDelta where TStructuralType : class
+ public class Delta : TypedDelta, IDelta, IDeltaSetItem where TStructuralType : class
{
// cache property accessors for this type and all its derived types.
- private static ConcurrentDictionary>> _propertyCache
+ private static readonly ConcurrentDictionary>> _propertyCache
= new ConcurrentDictionary>>();
private Dictionary> _allProperties;
- private HashSet _updatableProperties;
+ private List _updatableProperties;
private HashSet _changedProperties;
@@ -38,10 +45,12 @@ private static ConcurrentDictionary _changedDynamicProperties;
private IDictionary _dynamicDictionaryCache;
-
+ private NavigationPath _navigationPath;
+
///
/// Initializes a new instance of .
///
@@ -70,8 +79,24 @@ public Delta(Type structuralType)
/// The set of properties that can be updated or reset. Unknown property
/// names, including those of dynamic properties, are ignored.
public Delta(Type structuralType, IEnumerable updatableProperties)
- : this(structuralType, updatableProperties: updatableProperties, dynamicDictionaryPropertyInfo: null)
+ : this(structuralType, updatableProperties: updatableProperties, dynamicDictionaryPropertyInfo: null, instanceAnnotationsPropertyInfo:null)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of .
+ ///
+ /// The derived entity type or complex type for which the changes would be tracked.
+ /// should be assignable to instances of .
+ ///
+ /// The set of properties that can be updated or reset. Unknown property
+ /// names, including those of dynamic properties, are ignored.
+ /// The property info that is used as dictionary of dynamic
+ /// properties. null means this entity type is not open.
+ public Delta(Type structuralType, IEnumerable updatableProperties, PropertyInfo dynamicDictionaryPropertyInfo)
+ : this(structuralType, updatableProperties: updatableProperties, dynamicDictionaryPropertyInfo, instanceAnnotationsPropertyInfo: null)
{
+
}
///
@@ -83,29 +108,54 @@ public Delta(Type structuralType, IEnumerable updatableProperties)
/// The set of properties that can be updated or reset. Unknown property
/// names, including those of dynamic properties, are ignored.
/// The property info that is used as dictionary of dynamic
- /// properties. null means this entity type is not open.
+ /// properties. null means this entity type is not open.
+ /// The property info that is used as container for Instance Annotations
public Delta(Type structuralType, IEnumerable updatableProperties,
- PropertyInfo dynamicDictionaryPropertyInfo)
+ PropertyInfo dynamicDictionaryPropertyInfo, PropertyInfo instanceAnnotationsPropertyInfo)
{
_dynamicDictionaryPropertyinfo = dynamicDictionaryPropertyInfo;
Reset(structuralType);
- InitializeProperties(updatableProperties);
+ InitializeProperties(updatableProperties);
+ TransientInstanceAnnotationContainer = new ODataInstanceAnnotationContainer();
+ _instanceAnnotationsPropertyInfo = instanceAnnotationsPropertyInfo;
+ _navigationPath = new NavigationPath(structuralType.Name, null);
+ DeltaKind = EdmDeltaEntityKind.Entry;
}
///
public override Type StructuredType
+ => _structuredType;
+
+ internal IDictionary DeltaNestedResources
{
- get
- {
- return _structuredType;
- }
+ get { return _deltaNestedResources; }
}
///
public override Type ExpectedClrType
- {
- get { return typeof(TStructuralType); }
- }
+ => typeof(TStructuralType);
+
+ ///
+ /// The list of property names that can be updated.
+ ///
+ /// When the list is modified, any modified properties that were removed from the list are no longer
+ /// considered to be changed.
+ public IList UpdatableProperties
+ => _updatableProperties;
+
+ ///
+ /// Gets the enum type of .
+ ///
+ public EdmDeltaEntityKind DeltaKind { get; protected set; }
+
+ ///
+ public IODataInstanceAnnotationContainer TransientInstanceAnnotationContainer { get; set; }
+
+ ///
+ public ODataIdContainer ODataIdContainer { get; set; }
+
+ ///
+ internal PropertyInfo InstanceAnnotationsPropertyInfo { get { return _instanceAnnotationsPropertyInfo; } }
///
public override void Clear()
@@ -116,11 +166,24 @@ public override void Clear()
///
public override bool TrySetPropertyValue(string name, object value)
{
- if (string.IsNullOrWhiteSpace(name))
+ if (String.IsNullOrWhiteSpace(name))
{
throw Error.ArgumentNull("name");
}
+ if (_instanceAnnotationsPropertyInfo != null && name == _instanceAnnotationsPropertyInfo.Name)
+ {
+ IODataInstanceAnnotationContainer annotationValue = value as IODataInstanceAnnotationContainer;
+ if (value != null && annotationValue == null)
+ {
+ return false;
+ }
+
+ _instanceAnnotationsPropertyInfo.SetValue(_instance, annotationValue);
+
+ return true;
+ }
+
if (_dynamicDictionaryPropertyinfo != null)
{
// Dynamic property can have the same name as the dynamic property dictionary.
@@ -139,7 +202,7 @@ public override bool TrySetPropertyValue(string name, object value)
}
}
- if (value is IDelta)
+ if (value is IDelta || value is IDeltaSet)
{
return TrySetNestedResourceInternal(name, value);
}
@@ -157,6 +220,19 @@ public override bool TryGetPropertyValue(string name, out object value)
throw Error.ArgumentNull("name");
}
+ if (_instanceAnnotationsPropertyInfo != null && name == _instanceAnnotationsPropertyInfo.Name)
+ {
+ object propertyValue = _instanceAnnotationsPropertyInfo.GetValue(_instance);
+ if (propertyValue != null)
+ {
+ value = (IODataInstanceAnnotationContainer)propertyValue;
+ return true;
+ }
+
+ value = null;
+ return false;
+ }
+
if (_dynamicDictionaryPropertyinfo != null)
{
if (_dynamicDictionaryCache == null)
@@ -171,12 +247,20 @@ public override bool TryGetPropertyValue(string name, out object value)
}
}
- if (this._deltaNestedResources.ContainsKey(name))
+ if (_deltaNestedResources.ContainsKey(name))
{
// If this is a nested resource, get the value from the dictionary of nested resources.
object deltaNestedResource = _deltaNestedResources[name];
Contract.Assert(deltaNestedResource != null, "deltaNestedResource != null");
+
+ //If DeltaSet collection, we are handling delta collections so the value will be that itself and no need to get instance value
+ if (deltaNestedResource is IDeltaSet)
+ {
+ value = deltaNestedResource;
+ return true;
+ }
+
Contract.Assert(IsDeltaOfT(deltaNestedResource.GetType()));
// Get the Delta<{NestedResourceType}>._instance using Reflection.
@@ -259,7 +343,7 @@ public TStructuralType GetInstance()
///
public override IEnumerable GetChangedPropertyNames()
{
- return _changedProperties.Concat(_deltaNestedResources.Keys);
+ return _changedProperties.Intersect(_updatableProperties).Concat(_deltaNestedResources.Keys);
}
///
@@ -269,7 +353,8 @@ public override IEnumerable GetChangedPropertyNames()
///
public override IEnumerable GetUnchangedPropertyNames()
{
- return _updatableProperties.Except(GetChangedPropertyNames());
+ // UpdatableProperties could include arbitrary strings, filter by _allProperties
+ return _updatableProperties.Intersect(_allProperties.Keys).Except(GetChangedPropertyNames());
}
///
@@ -278,6 +363,13 @@ public override IEnumerable GetUnchangedPropertyNames()
///
/// The entity to be updated.
public void CopyChangedValues(TStructuralType original)
+ {
+ CopyChangedValues(original, null);
+ }
+
+ [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
+ [SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
+ internal void CopyChangedValues(TStructuralType original, ODataAPIHandler apiHandler = null, ODataAPIHandlerFactory apiHandlerFactory = null)
{
if (original == null)
{
@@ -291,11 +383,17 @@ public void CopyChangedValues(TStructuralType original)
throw Error.Argument("original", SRResources.DeltaTypeMismatch, _structuredType, original.GetType());
}
+ //To apply ODataId if its present
+ if (apiHandlerFactory != null && ODataIdContainer?.ODataIdNavigationPath != null)
+ {
+ ApplyODataId(original, apiHandlerFactory);
+ }
+
RuntimeHelpers.EnsureSufficientExecutionStack();
// For regular non-structural properties at current level.
PropertyAccessor[] propertiesToCopy =
- this._changedProperties.Select(s => _allProperties[s]).ToArray();
+ _changedProperties.Intersect(_updatableProperties).Select(s => _allProperties[s]).ToArray();
foreach (PropertyAccessor propertyToCopy in propertiesToCopy)
{
propertyToCopy.Copy(_instance, original);
@@ -309,31 +407,45 @@ public void CopyChangedValues(TStructuralType original)
// Patch for each nested resource changed under this TStructuralType.
dynamic deltaNestedResource = _deltaNestedResources[nestedResourceName];
dynamic originalNestedResource = null;
- if (!TryGetPropertyRef(original, nestedResourceName, out originalNestedResource))
- {
- throw Error.Argument(nestedResourceName, SRResources.DeltaNestedResourceNameNotFound,
- nestedResourceName, original.GetType());
- }
- if (originalNestedResource == null)
+ if(deltaNestedResource is IDeltaSet)
{
- // When patching original target of null value, directly set nested resource.
- dynamic deltaObject = _deltaNestedResources[nestedResourceName];
- dynamic instance = deltaObject.GetInstance();
-
- // Recursively patch up the instance with the nested resources.
- deltaObject.CopyChangedValues(instance);
+ IODataAPIHandler apiHandlerNested = apiHandler.GetNestedHandler(original, nestedResourceName);
- _allProperties[nestedResourceName].SetValue(original, instance);
+ if (apiHandlerNested != null)
+ {
+ deltaNestedResource.CopyChangedValues(apiHandlerNested, apiHandlerFactory);
+ }
}
else
{
- // Recursively patch the subtree.
- bool isDeltaType = TypedDelta.IsDeltaOfT(deltaNestedResource.GetType());
- Contract.Assert(isDeltaType, nestedResourceName + "'s corresponding value should be Delta type but is not.");
+ if (!TryGetPropertyRef(original, nestedResourceName, out originalNestedResource))
+ {
+ throw Error.Argument(nestedResourceName, SRResources.DeltaNestedResourceNameNotFound,
+ nestedResourceName, original.GetType());
+ }
+
+ if (originalNestedResource == null)
+ {
+ // When patching original target of null value, directly set nested resource.
+ dynamic deltaObject = _deltaNestedResources[nestedResourceName];
+ dynamic instance = deltaObject.GetInstance();
+
+ // Recursively patch up the instance with the nested resources.
+ deltaObject.CopyChangedValues(instance);
- deltaNestedResource.CopyChangedValues(originalNestedResource);
+ _allProperties[nestedResourceName].SetValue(original, instance);
+ }
+ else
+ {
+ //Recursively patch the subtree.
+ bool isDeltaType = TypedDelta.IsDeltaOfT(deltaNestedResource.GetType());
+ Contract.Assert(isDeltaType, nestedResourceName + "'s corresponding value should be Delta type but is not.");
+
+ deltaNestedResource.CopyChangedValues(originalNestedResource);
+ }
}
+
}
}
@@ -373,6 +485,51 @@ public void Patch(TStructuralType original)
CopyChangedValues(original);
}
+ ///
+ /// Overwrites the entity with the changes tracked by this Delta.
+ /// The semantics of this operation are equivalent to a HTTP PATCH operation, hence the name.
+ ///
+ /// The entity to be updated.
+ /// API Handler Factory
+ public void Patch(TStructuralType original, ODataAPIHandlerFactory apiHandlerFactory)
+ {
+ IODataAPIHandler apiHandler = apiHandlerFactory.GetHandler(_navigationPath);
+
+ Debug.Assert(apiHandler != null);
+
+ CopyChangedValues(original, apiHandler as ODataAPIHandler, apiHandlerFactory);
+ }
+
+ ///
+ /// This is basically Patch on ODataId. This applies ODataId parsed Navigation paths, get the value identified by that and copy it on original object
+ ///
+ private void ApplyODataId(TStructuralType original, ODataAPIHandlerFactory apiHandlerFactory)
+ {
+ IODataAPIHandler refapiHandler = apiHandlerFactory.GetHandler(ODataIdContainer.ODataIdNavigationPath);
+
+ if (refapiHandler != null)
+ {
+ ODataAPIHandler refapiHandlerOfT = refapiHandler as ODataAPIHandler;
+
+ Debug.Assert(refapiHandlerOfT != null);
+
+ TStructuralType referencedObj;
+ string error;
+
+ //Checking to get the referenced entity, get the properties and apply it on original object
+ if (refapiHandlerOfT.TryGet(ODataIdContainer.ODataIdNavigationPath.GetNavigationPathItems().Last().KeyProperties, out referencedObj, out error) == ODataAPIResponseStatus.Success)
+ {
+ foreach (string property in _updatableProperties)
+ {
+ PropertyInfo propertyInfo = _structuredType.GetProperty(property);
+
+ object value = propertyInfo.GetValue(referencedObj);
+ propertyInfo.SetValue(original, value);
+ }
+ }
+ }
+ }
+
///
/// Overwrites the entity with the values stored in this Delta.
/// The semantics of this operation are equivalent to a HTTP PUT operation, hence the name.
@@ -502,15 +659,14 @@ private void InitializeProperties(IEnumerable updatableProperties)
.Where(p => (p.GetSetMethod() != null || TypeHelper.IsCollection(p.PropertyType)) && p.GetGetMethod() != null)
.Select>(p => new FastPropertyAccessor(p))
.ToDictionary(p => p.Property.Name));
-
+
if (updatableProperties != null)
{
- _updatableProperties = new HashSet(updatableProperties);
- _updatableProperties.IntersectWith(_allProperties.Keys);
+ _updatableProperties = updatableProperties.Intersect(_allProperties.Keys).ToList();
}
else
{
- _updatableProperties = new HashSet(_allProperties.Keys);
+ _updatableProperties = new List(_allProperties.Keys);
}
if (_dynamicDictionaryPropertyinfo != null)
@@ -625,7 +781,7 @@ private bool TrySetPropertyValueInternal(string name, object value)
throw Error.ArgumentNull("name");
}
- if (!_updatableProperties.Contains(name))
+ if (!(_allProperties.ContainsKey(name) && _updatableProperties.Contains(name)))
{
return false;
}
@@ -655,7 +811,7 @@ private bool TrySetNestedResourceInternal(string name, object deltaNestedResourc
throw Error.ArgumentNull("name");
}
- if (!_updatableProperties.Contains(name))
+ if (!(_allProperties.ContainsKey(name) && _updatableProperties.Contains(name)))
{
return false;
}
@@ -666,11 +822,16 @@ private bool TrySetNestedResourceInternal(string name, object deltaNestedResourc
return false;
}
- PropertyAccessor cacheHit = _allProperties[name];
- // Get the Delta<{NestedResourceType}>._instance using Reflection.
- FieldInfo field = deltaNestedResource.GetType().GetField("_instance", BindingFlags.NonPublic | BindingFlags.Instance);
- Contract.Assert(field != null, "field != null");
- cacheHit.SetValue(_instance, field.GetValue(deltaNestedResource));
+ //If Edmchangedobject collection, we are handling delta collections so the instance value need not be set,
+ //as we consider the value as collection of Delta itself and not instance value of the field
+ if (!(deltaNestedResource is IDeltaSet))
+ {
+ PropertyAccessor cacheHit = _allProperties[name];
+ // Get the Delta<{NestedResourceType}>._instance using Reflection.
+ FieldInfo field = deltaNestedResource.GetType().GetField("_instance", BindingFlags.NonPublic | BindingFlags.Instance);
+ Contract.Assert(field != null, "field != null");
+ cacheHit.SetValue(_instance, field.GetValue(deltaNestedResource));
+ }
// Add the nested resource in the hierarchy.
// Note: We shouldn't add the structural properties to the _changedProperties
, which
@@ -680,4 +841,4 @@ private bool TrySetNestedResourceInternal(string name, object deltaNestedResourc
return true;
}
}
-}
+}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.OData.Shared/DeltaSetOfT.cs b/src/Microsoft.AspNet.OData.Shared/DeltaSetOfT.cs
new file mode 100644
index 0000000000..2d1e4f9f19
--- /dev/null
+++ b/src/Microsoft.AspNet.OData.Shared/DeltaSetOfT.cs
@@ -0,0 +1,342 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Diagnostics;
+using System.Diagnostics.Contracts;
+using System.Linq;
+using System.Reflection;
+using Microsoft.AspNet.OData.Builder;
+using Microsoft.AspNet.OData.Common;
+using Org.OData.Core.V1;
+
+namespace Microsoft.AspNet.OData
+{
+ ///
+ /// Represents an that is a collection of s.
+ ///
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
+ [NonValidatingParameterBinding]
+ public class DeltaSet : Collection, IDeltaSet where TStructuralType : class
+ {
+ private Type _clrType;
+ IList _keys;
+ NavigationPath _navigationPath;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// List of key names for the type
+ public DeltaSet(IList keys)
+ {
+ _keys = keys;
+ _clrType = typeof(TStructuralType);
+ _navigationPath = new NavigationPath(_clrType.Name, null);
+ }
+
+
+ ///
+ protected override void InsertItem(int index, IDeltaSetItem item)
+ {
+ Delta deltaItem = item as Delta;
+
+ //To ensure we dont insert null or a non related type to deltaset
+ if (deltaItem == null)
+ {
+ throw Error.Argument("item", SRResources.ChangedObjectTypeMismatch, item.GetType(), _clrType);
+ }
+
+ base.InsertItem(index, item);
+ }
+
+
+ ///
+ /// Patch for DeltaSet, a collection for Delta
+ ///
+ /// Original collection of the Type which needs to be updated
+ /// /// DeltaSet response
+ public DeltaSet Patch(ICollection originalCollection)
+ {
+ ODataAPIHandler apiHandler = new DefaultODataAPIHandler(originalCollection);
+
+ return CopyChangedValues(apiHandler);
+ }
+
+
+ ///
+ /// Patch for DeltaSet, a collection for Delta
+ ///
+ /// DeltaSet response
+ public DeltaSet Patch(ODataAPIHandlerFactory apiHandlerFactory)
+ {
+ IODataAPIHandler apiHandler = apiHandlerFactory.GetHandler(_navigationPath);
+ ODataAPIHandler apiHandlerOfT = apiHandler as ODataAPIHandler;
+ Debug.Assert(apiHandlerOfT != null);
+
+ return CopyChangedValues(apiHandlerOfT, apiHandlerFactory);
+ }
+
+
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
+ internal DeltaSet CopyChangedValues(IODataAPIHandler apiHandler, ODataAPIHandlerFactory apiHandlerFactory = null)
+ {
+ //Here we are getting the keys and using the keys to find the original object
+ //to patch from the list of collection
+
+ ODataAPIHandler apiHandlerOfT = apiHandler as ODataAPIHandler;
+
+ Debug.Assert(apiHandlerOfT != null);
+
+ DeltaSet deltaSet = CreateDeltaSet();
+
+ foreach (Delta changedObj in Items)
+ {
+ DataModificationOperationKind operation = DataModificationOperationKind.Update;
+
+ //Get filtered item based on keys
+ TStructuralType original = null;
+ string errorMessage = string.Empty;
+ string getErrorMessage = string.Empty;
+
+ Dictionary keyValues = new Dictionary();
+
+ foreach (string key in _keys)
+ {
+ object value;
+
+ if (changedObj.TryGetPropertyValue(key, out value))
+ {
+ keyValues.Add(key, value);
+ }
+ }
+
+ try
+ {
+ ODataAPIResponseStatus ODataAPIResponseStatus = apiHandlerOfT.TryGet(keyValues, out original, out getErrorMessage);
+
+ DeltaDeletedEntityObject deletedObj = changedObj as DeltaDeletedEntityObject;
+
+ if (ODataAPIResponseStatus == ODataAPIResponseStatus.Failure || (deletedObj != null && ODataAPIResponseStatus == ODataAPIResponseStatus.NotFound))
+ {
+ IDeltaSetItem deltaSetItem = changedObj;
+
+ DataModificationExceptionType dataModificationExceptionType = new DataModificationExceptionType(operation);
+ dataModificationExceptionType.MessageType = new MessageType { Message = getErrorMessage };
+
+ deltaSetItem.TransientInstanceAnnotationContainer.AddResourceAnnotation(SRResources.DataModificationException, dataModificationExceptionType);
+
+ deltaSet.Add(deltaSetItem);
+
+ continue;
+ }
+
+ if (deletedObj != null)
+ {
+ operation = DataModificationOperationKind.Delete;
+
+ changedObj.CopyChangedValues(original, apiHandlerOfT, apiHandlerFactory);
+
+ if (apiHandlerOfT.TryDelete(keyValues, out errorMessage) != ODataAPIResponseStatus.Success)
+ {
+ //Handle Failed Operation - Delete
+
+ if (ODataAPIResponseStatus == ODataAPIResponseStatus.Success)
+ {
+ IDeltaSetItem changedObject = HandleFailedOperation(changedObj, operation, original, errorMessage);
+ deltaSet.Add(changedObject);
+ continue;
+ }
+ }
+
+ deltaSet.Add(deletedObj);
+ }
+ else
+ {
+ if (ODataAPIResponseStatus == ODataAPIResponseStatus.NotFound)
+ {
+ operation = DataModificationOperationKind.Insert;
+
+ if (apiHandlerOfT.TryCreate(keyValues, out original, out errorMessage) != ODataAPIResponseStatus.Success)
+ {
+ //Handle failed Opreataion - create
+ IDeltaSetItem changedObject = HandleFailedOperation(changedObj, operation, original, errorMessage);
+ deltaSet.Add(changedObject);
+ continue;
+ }
+ }
+ else if (ODataAPIResponseStatus == ODataAPIResponseStatus.Success)
+ {
+ operation = DataModificationOperationKind.Update;
+ }
+ else
+ {
+ //Handle failed operation
+ IDeltaSetItem changedObject = HandleFailedOperation(changedObj, operation, original, getErrorMessage);
+ deltaSet.Add(changedObject);
+ continue;
+ }
+
+ //Patch for addition/update. This will call Delta for each item in the collection
+ // This will work in case we use delegates for using users method to create an object
+ changedObj.CopyChangedValues(original, apiHandlerOfT, apiHandlerFactory);
+
+ deltaSet.Add(changedObj);
+ }
+ }
+ catch (Exception ex)
+ {
+ //For handling the failed operations.
+ IDeltaSetItem changedObject = HandleFailedOperation(changedObj, operation, original, ex.Message);
+ deltaSet.Add(changedObject);
+ }
+ }
+
+ return deltaSet;
+ }
+
+ private DeltaSet CreateDeltaSet()
+ {
+ Type type = typeof(DeltaSet<>).MakeGenericType(_clrType);
+
+ return Activator.CreateInstance(type, _keys) as DeltaSet;
+ }
+
+ private IDeltaSetItem HandleFailedOperation(Delta changedObj, DataModificationOperationKind operation, TStructuralType originalObj, string errorMessage)
+ {
+ IDeltaSetItem deltaSetItem = null;
+ DataModificationExceptionType dataModificationExceptionType = new DataModificationExceptionType(operation);
+ dataModificationExceptionType.MessageType = new MessageType { Message = errorMessage };
+
+ // This handles the Data Modification exception. This adds Core.DataModificationException annotation and also copy other instance annotations.
+ //The failed operation will be based on the protocol
+ switch (operation)
+ {
+ case DataModificationOperationKind.Update:
+ deltaSetItem = changedObj;
+ break;
+ case DataModificationOperationKind.Insert:
+ {
+ deltaSetItem = CreateDeletedEntityForFailedOperation(changedObj);
+
+ break;
+ }
+ case DataModificationOperationKind.Delete:
+ {
+ deltaSetItem = CreateEntityObjectForFailedOperation(changedObj, originalObj);
+ break;
+ }
+ }
+
+
+ deltaSetItem.TransientInstanceAnnotationContainer = changedObj.TransientInstanceAnnotationContainer;
+ deltaSetItem.TransientInstanceAnnotationContainer.AddResourceAnnotation(SRResources.DataModificationException, dataModificationExceptionType);
+
+ Contract.Assert(deltaSetItem != null);
+
+ return deltaSetItem;
+ }
+
+ private IDeltaSetItem CreateEntityObjectForFailedOperation(Delta changedObj, TStructuralType originalObj)
+ {
+ Type type = typeof(Delta<>).MakeGenericType(_clrType);
+
+ Delta deltaObject = Activator.CreateInstance(type, _clrType, null, null,
+ changedObj.InstanceAnnotationsPropertyInfo) as Delta;
+
+ SetProperties(originalObj, deltaObject);
+
+ if (deltaObject.InstanceAnnotationsPropertyInfo != null)
+ {
+ object instAnnValue;
+ changedObj.TryGetPropertyValue(deltaObject.InstanceAnnotationsPropertyInfo.Name, out instAnnValue);
+ if (instAnnValue != null)
+ {
+ IODataInstanceAnnotationContainer instanceAnnotations = instAnnValue as IODataInstanceAnnotationContainer;
+
+ if (instanceAnnotations != null)
+ {
+ deltaObject.TrySetPropertyValue(deltaObject.InstanceAnnotationsPropertyInfo.Name, instanceAnnotations);
+ }
+ }
+ }
+
+ return deltaObject;
+ }
+
+ private void SetProperties(TStructuralType originalObj, Delta edmDeltaEntityObject)
+ {
+ foreach (string property in edmDeltaEntityObject.GetUnchangedPropertyNames())
+ {
+ edmDeltaEntityObject.TrySetPropertyValue(property, _clrType.GetProperty(property).GetValue(originalObj));
+ }
+ }
+
+ private DeltaDeletedEntityObject CreateDeletedEntityForFailedOperation(Delta changedObj)
+ {
+ Type type = typeof(DeltaDeletedEntityObject<>).MakeGenericType(changedObj.ExpectedClrType);
+
+ DeltaDeletedEntityObject deletedObject = Activator.CreateInstance(type, true, changedObj.InstanceAnnotationsPropertyInfo) as DeltaDeletedEntityObject;
+
+ foreach (string property in changedObj.GetChangedPropertyNames())
+ {
+ SetPropertyValues(changedObj, deletedObject, property);
+ }
+
+ foreach (string property in changedObj.GetUnchangedPropertyNames())
+ {
+ SetPropertyValues(changedObj, deletedObject, property);
+ }
+
+ object annValue;
+ if (changedObj.TryGetPropertyValue(changedObj.InstanceAnnotationsPropertyInfo.Name, out annValue))
+ {
+ IODataInstanceAnnotationContainer instanceAnnotations = annValue as IODataInstanceAnnotationContainer;
+
+ if (instanceAnnotations != null)
+ {
+ deletedObject.TrySetPropertyValue(changedObj.InstanceAnnotationsPropertyInfo.Name, instanceAnnotations);
+ }
+ }
+
+ deletedObject.TransientInstanceAnnotationContainer = changedObj.TransientInstanceAnnotationContainer;
+
+ ValidateForDeletedEntityId(_keys, deletedObject);
+
+ return deletedObject;
+ }
+
+ //This is for ODL to work to set id as empty, because if there are missing keys, id wouldnt be set and we need to set it as empty.
+ private static void ValidateForDeletedEntityId(IList keys, DeltaDeletedEntityObject edmDeletedObject)
+ {
+ bool hasnullKeys = false;
+ for (int i = 0; i < keys.Count; i++)
+ {
+ object value;
+ edmDeletedObject.TryGetPropertyValue(keys[i], out value);
+
+ if (value == null)
+ {
+ hasnullKeys = true;
+ break;
+ }
+ }
+
+ if (hasnullKeys)
+ {
+ edmDeletedObject.Id = new Uri(string.Empty);
+ }
+ }
+
+ private static void SetPropertyValues(Delta changedObj, DeltaDeletedEntityObject edmDeletedObject, string property)
+ {
+ object objectVal;
+ if (changedObj.TryGetPropertyValue(property, out objectVal))
+ {
+ edmDeletedObject.TrySetPropertyValue(property, objectVal);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.OData.Shared/ETagMessageHandler.cs b/src/Microsoft.AspNet.OData.Shared/ETagMessageHandler.cs
index 003071384c..e60f8f5b55 100644
--- a/src/Microsoft.AspNet.OData.Shared/ETagMessageHandler.cs
+++ b/src/Microsoft.AspNet.OData.Shared/ETagMessageHandler.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Diagnostics.Contracts;
diff --git a/src/Microsoft.AspNet.OData.Shared/EdmChangedObjectCollection.cs b/src/Microsoft.AspNet.OData.Shared/EdmChangedObjectCollection.cs
index 1af4915c28..82a7b9758e 100644
--- a/src/Microsoft.AspNet.OData.Shared/EdmChangedObjectCollection.cs
+++ b/src/Microsoft.AspNet.OData.Shared/EdmChangedObjectCollection.cs
@@ -1,11 +1,22 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
+using System;
+using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.Diagnostics;
+using System.Diagnostics.Contracts;
using System.Linq;
+using System.Net.Http.Headers;
using Microsoft.AspNet.OData.Common;
+using Microsoft.OData;
using Microsoft.OData.Edm;
+using Org.OData.Core.V1;
namespace Microsoft.AspNet.OData
{
@@ -18,7 +29,8 @@ public class EdmChangedObjectCollection : Collection, IEdmObj
private IEdmEntityType _entityType;
private EdmDeltaCollectionType _edmType;
private IEdmCollectionTypeReference _edmTypeReference;
-
+ private NavigationPath _navigationPath;
+
///
/// Initializes a new instance of the class.
///
@@ -39,7 +51,13 @@ public EdmChangedObjectCollection(IEdmEntityType entityType, IList
+ /// Represents EntityType of the changedobject
+ ///
+ public IEdmEntityType EntityType { get { return _entityType; } }
+
///
public IEdmTypeReference GetEdmType()
{
@@ -56,6 +74,321 @@ private void Initialize(IEdmEntityType entityType)
_entityType = entityType;
_edmType = new EdmDeltaCollectionType(new EdmEntityTypeReference(_entityType, isNullable: true));
_edmTypeReference = new EdmCollectionTypeReference(_edmType);
+ _navigationPath = new NavigationPath(entityType.Name, null);
+ }
+
+ ///
+ /// Patch for Types without underlying CLR types
+ ///
+ ///
+ /// ChangedObjectCollection response
+ internal EdmChangedObjectCollection Patch(ICollection originalCollection)
+ {
+ EdmODataAPIHandler apiHandler = new DefaultEdmODataAPIHandler(originalCollection, _entityType);
+
+ return CopyChangedValues(apiHandler);
+ }
+
+ ///
+ /// Patch for EdmChangedObjectCollection, a collection for IEdmChangedObject
+ ///
+ /// ChangedObjectCollection response
+ public EdmChangedObjectCollection Patch(ODataEdmAPIHandlerFactory apiHandlerFactory)
+ {
+ EdmODataAPIHandler apiHandler = apiHandlerFactory.GetHandler(_navigationPath);
+
+ return CopyChangedValues(apiHandler, apiHandlerFactory);
+ }
+
+
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling")]
+ internal EdmChangedObjectCollection CopyChangedValues(EdmODataAPIHandler apiHandler, ODataEdmAPIHandlerFactory apiHandlerFactory = null)
+ {
+ EdmChangedObjectCollection changedObjectCollection = new EdmChangedObjectCollection(_entityType);
+ IEdmStructuralProperty[] keys = _entityType.Key().ToArray();
+
+ foreach (IEdmChangedObject changedObj in Items)
+ {
+ DataModificationOperationKind operation = DataModificationOperationKind.Update;
+ EdmStructuredObject originalObj = null;
+ string errorMessage = string.Empty;
+ string getErrorMessage = string.Empty;
+ IDictionary keyValues = GetKeyValues(keys, changedObj);
+
+ try
+ {
+ IEdmStructuredObject original = null;
+ EdmDeltaDeletedEntityObject deletedObj = changedObj as EdmDeltaDeletedEntityObject;
+
+ ODataAPIResponseStatus ODataAPIResponseStatus = apiHandler.TryGet(keyValues, out original, out getErrorMessage);
+
+ if (ODataAPIResponseStatus == ODataAPIResponseStatus.Failure || (deletedObj != null && ODataAPIResponseStatus == ODataAPIResponseStatus.NotFound))
+ {
+ DataModificationExceptionType dataModificationExceptionType = new DataModificationExceptionType(operation);
+ dataModificationExceptionType.MessageType = new MessageType { Message = getErrorMessage };
+
+ deletedObj.TransientInstanceAnnotationContainer.AddResourceAnnotation(SRResources.DataModificationException, dataModificationExceptionType);
+
+ changedObjectCollection.Add(deletedObj);
+
+ continue;
+ }
+
+ if (deletedObj != null)
+ {
+ operation = DataModificationOperationKind.Delete;
+
+ PatchItem(deletedObj, original as EdmStructuredObject, apiHandler, apiHandlerFactory);
+
+ if (apiHandler.TryDelete(keyValues, out errorMessage) != ODataAPIResponseStatus.Success)
+ {
+ //Handle Failed Operation - Delete
+ if (ODataAPIResponseStatus == ODataAPIResponseStatus.Success)
+ {
+ IEdmChangedObject changedObject = HandleFailedOperation(deletedObj, operation, original, keys, errorMessage, apiHandler);
+ changedObjectCollection.Add(changedObject);
+ continue;
+ }
+ }
+
+
+
+ changedObjectCollection.Add(deletedObj);
+ }
+ else
+ {
+ EdmEntityObject deltaEntityObject = changedObj as EdmEntityObject;
+
+ if (ODataAPIResponseStatus == ODataAPIResponseStatus.NotFound)
+ {
+ operation = DataModificationOperationKind.Insert;
+
+ if (apiHandler.TryCreate(changedObj, out original, out errorMessage) != ODataAPIResponseStatus.Success)
+ {
+ //Handle failed Opreataion - create
+ IEdmChangedObject changedObject = HandleFailedOperation(deltaEntityObject, operation, original, keys, errorMessage, apiHandler);
+ changedObjectCollection.Add(changedObject);
+ continue;
+ }
+ }
+ else if (ODataAPIResponseStatus == ODataAPIResponseStatus.Success)
+ {
+ operation = DataModificationOperationKind.Update;
+ }
+ else
+ {
+ //Handle failed operation
+ IEdmChangedObject changedObject = HandleFailedOperation(deltaEntityObject, operation, null, keys, getErrorMessage, apiHandler);
+ changedObjectCollection.Add(changedObject);
+ continue;
+ }
+
+ //Patch for addition/update.
+ PatchItem(deltaEntityObject, original as EdmStructuredObject, apiHandler, apiHandlerFactory);
+
+ changedObjectCollection.Add(changedObj);
+ }
+ }
+ catch (Exception ex)
+ {
+ //Handle Failed Operation
+ IEdmChangedObject changedObject = HandleFailedOperation(changedObj as EdmEntityObject, operation, originalObj, keys, ex.Message, apiHandler);
+
+ Contract.Assert(changedObject != null);
+ changedObjectCollection.Add(changedObject);
+ }
+ }
+
+ return changedObjectCollection;
+ }
+
+ private static IDictionary GetKeyValues(IEdmStructuralProperty [] keys, IEdmChangedObject changedObj)
+ {
+ IDictionary keyValues = new Dictionary();
+
+ foreach (IEdmStructuralProperty key in keys)
+ {
+ object value;
+ changedObj.TryGetPropertyValue(key.Name, out value);
+
+ if (value != null)
+ {
+ keyValues.Add(key.Name, value);
+ }
+ }
+
+ return keyValues;
+ }
+
+ private void PatchItem(EdmStructuredObject changedObj, EdmStructuredObject originalObj, EdmODataAPIHandler apiHandler, ODataEdmAPIHandlerFactory apiHandlerFactory = null)
+ {
+ if(apiHandlerFactory!= null && changedObj is EdmEntityObject entityObject && entityObject.ODataIdContainer != null)
+ {
+ ApplyODataId(entityObject.ODataIdContainer, originalObj, apiHandlerFactory);
+ }
+
+ foreach (string propertyName in changedObj.GetChangedPropertyNames())
+ {
+ ApplyProperties(changedObj, originalObj, propertyName, apiHandler, apiHandlerFactory);
+ }
+ }
+
+ ///
+ /// This applies ODataId parsed Navigation paths, get the value identified by that and copy it on original object, for typeless entities
+ ///
+ private void ApplyODataId(ODataIdContainer container, EdmStructuredObject original, ODataEdmAPIHandlerFactory apiHandlerFactory)
+ {
+ EdmODataAPIHandler edmApiHandler = apiHandlerFactory.GetHandler(container.ODataIdNavigationPath);
+
+ if(edmApiHandler == null)
+ {
+ return;
+ }
+
+ IEdmStructuredObject referencedObj;
+ string error;
+
+ if (edmApiHandler.TryGet(container.ODataIdNavigationPath.GetNavigationPathItems().Last().KeyProperties, out referencedObj, out error) == ODataAPIResponseStatus.Success)
+ {
+ EdmStructuredObject structuredObj = referencedObj as EdmStructuredObject;
+
+ foreach (string propertyName in structuredObj.GetChangedPropertyNames())
+ {
+ ApplyProperties(structuredObj, original, propertyName, edmApiHandler, apiHandlerFactory);
+ }
+
+ foreach (string propertyName in structuredObj.GetUnchangedPropertyNames())
+ {
+ ApplyProperties(structuredObj, original, propertyName, edmApiHandler, apiHandlerFactory);
+ }
+ }
+ }
+
+
+ private void ApplyProperties(EdmStructuredObject changedObj, EdmStructuredObject originalObj, string propertyName, EdmODataAPIHandler apiHandler, ODataEdmAPIHandlerFactory apiHandlerFactory = null)
+ {
+ object value;
+ if (changedObj.TryGetPropertyValue(propertyName, out value))
+ {
+ EdmChangedObjectCollection changedColl = value as EdmChangedObjectCollection;
+ if (changedColl != null)
+ {
+ EdmODataAPIHandler apiHandlerNested = apiHandler.GetNestedHandler(originalObj, propertyName);
+ if (apiHandlerNested != null)
+ {
+ changedColl.CopyChangedValues(apiHandlerNested, apiHandlerFactory);
+ }
+ else
+ {
+ object obj;
+ originalObj.TryGetPropertyValue(propertyName, out obj);
+
+ ICollection edmColl = obj as ICollection;
+
+ changedColl.Patch(edmColl);
+ }
+ }
+ else
+ {
+ //call patchitem if its single structuredobj
+ EdmStructuredObject structuredObj = value as EdmStructuredObject;
+
+ if (structuredObj != null)
+ {
+ object obj;
+ originalObj.TryGetPropertyValue(propertyName, out obj);
+
+ EdmStructuredObject origStructuredObj = obj as EdmStructuredObject;
+
+ if(origStructuredObj == null)
+ {
+ if(structuredObj is EdmComplexObject)
+ {
+ origStructuredObj = new EdmComplexObject(structuredObj.ActualEdmType as IEdmComplexType);
+ }
+ else
+ {
+ origStructuredObj = new EdmEntityObject(structuredObj.ActualEdmType as IEdmEntityType);
+ }
+
+ originalObj.TrySetPropertyValue(propertyName, origStructuredObj);
+ }
+
+ PatchItem(structuredObj, origStructuredObj, apiHandler, apiHandlerFactory);
+ }
+ else
+ {
+ originalObj.TrySetPropertyValue(propertyName, value);
+ }
+ }
+ }
+ }
+
+ private IEdmChangedObject HandleFailedOperation(EdmEntityObject changedObj, DataModificationOperationKind operation, IEdmStructuredObject originalObj,
+ IEdmStructuralProperty[] keys, string errorMessage, EdmODataAPIHandler apiHandler)
+ {
+ IEdmChangedObject edmChangedObject = null;
+ DataModificationExceptionType dataModificationExceptionType = new DataModificationExceptionType(operation);
+ dataModificationExceptionType.MessageType = new MessageType { Message = errorMessage };
+
+ // This handles the Data Modification exception. This adds Core.DataModificationException annotation and also copy other instance annotations.
+ //The failed operation will be based on the protocol
+ switch (operation)
+ {
+ case DataModificationOperationKind.Update:
+ edmChangedObject = changedObj as IEdmChangedObject;
+ break;
+ case DataModificationOperationKind.Insert:
+ {
+ EdmDeltaDeletedEntityObject edmDeletedObject = new EdmDeltaDeletedEntityObject(EntityType);
+ PatchItem(edmDeletedObject, changedObj, apiHandler);
+
+ ValidateForDeletedEntityId(keys, edmDeletedObject);
+
+ edmDeletedObject.TransientInstanceAnnotationContainer = changedObj.TransientInstanceAnnotationContainer;
+ edmDeletedObject.PersistentInstanceAnnotationsContainer = changedObj.PersistentInstanceAnnotationsContainer;
+
+ edmDeletedObject.AddDataException(dataModificationExceptionType);
+ edmChangedObject = edmDeletedObject;
+ break;
+ }
+ case DataModificationOperationKind.Delete:
+ {
+ EdmDeltaEntityObject edmEntityObject = new EdmDeltaEntityObject(EntityType);
+ PatchItem(originalObj as EdmStructuredObject, edmEntityObject, apiHandler);
+
+ edmEntityObject.TransientInstanceAnnotationContainer = changedObj.TransientInstanceAnnotationContainer;
+ edmEntityObject.PersistentInstanceAnnotationsContainer = changedObj.PersistentInstanceAnnotationsContainer;
+
+ edmEntityObject.AddDataException( dataModificationExceptionType);
+ edmChangedObject = edmEntityObject;
+ break;
+ }
+ }
+
+ return edmChangedObject;
+ }
+
+ //This is for ODL to work to set id as empty, because if there are missing keys, id wouldnt be set and we need to set it as empty.
+ private static void ValidateForDeletedEntityId(IEdmStructuralProperty[] keys, EdmDeltaDeletedEntityObject edmDeletedObject)
+ {
+ bool hasNullKeys = false;
+ for (int i = 0; i < keys.Length; i++)
+ {
+ object value;
+ if (edmDeletedObject.TryGetPropertyValue(keys[i].Name, out value))
+ {
+ hasNullKeys = true;
+ break;
+ }
+ }
+
+ if (hasNullKeys)
+ {
+ edmDeletedObject.Id = string.Empty;
+ }
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/EdmComplexCollectionObject.cs b/src/Microsoft.AspNet.OData.Shared/EdmComplexCollectionObject.cs
index ab322a61eb..222a26e7f0 100644
--- a/src/Microsoft.AspNet.OData.Shared/EdmComplexCollectionObject.cs
+++ b/src/Microsoft.AspNet.OData.Shared/EdmComplexCollectionObject.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Collections.ObjectModel;
diff --git a/src/Microsoft.AspNet.OData.Shared/EdmComplexObject.cs b/src/Microsoft.AspNet.OData.Shared/EdmComplexObject.cs
index a7ee0a6a66..f20034df69 100644
--- a/src/Microsoft.AspNet.OData.Shared/EdmComplexObject.cs
+++ b/src/Microsoft.AspNet.OData.Shared/EdmComplexObject.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.OData.Edm;
diff --git a/src/Microsoft.AspNet.OData.Shared/EdmDeltaCollectionType.cs b/src/Microsoft.AspNet.OData.Shared/EdmDeltaCollectionType.cs
index 638d083532..e7f8aeac05 100644
--- a/src/Microsoft.AspNet.OData.Shared/EdmDeltaCollectionType.cs
+++ b/src/Microsoft.AspNet.OData.Shared/EdmDeltaCollectionType.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Common;
using Microsoft.OData.Edm;
@@ -40,4 +44,4 @@ public IEdmTypeReference ElementType
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/EdmDeltaComplexObject.cs b/src/Microsoft.AspNet.OData.Shared/EdmDeltaComplexObject.cs
index e5fd531c5f..12be9fcf21 100644
--- a/src/Microsoft.AspNet.OData.Shared/EdmDeltaComplexObject.cs
+++ b/src/Microsoft.AspNet.OData.Shared/EdmDeltaComplexObject.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.OData.Edm;
@@ -41,4 +45,4 @@ public EdmDeltaComplexObject(IEdmComplexType edmType, bool isNullable)
{
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/EdmDeltaDeletedEntityObject.cs b/src/Microsoft.AspNet.OData.Shared/EdmDeltaDeletedEntityObject.cs
index 25494d74ca..f548c7a44b 100644
--- a/src/Microsoft.AspNet.OData.Shared/EdmDeltaDeletedEntityObject.cs
+++ b/src/Microsoft.AspNet.OData.Shared/EdmDeltaDeletedEntityObject.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Diagnostics.Contracts;
@@ -76,12 +80,11 @@ public DeltaDeletedEntryReason Reason
}
///
- public EdmDeltaEntityKind DeltaKind
+ public override EdmDeltaEntityKind DeltaKind
{
get
- {
- Contract.Assert(_edmType != null);
- return _edmType.DeltaKind;
+ {
+ return EdmDeltaEntityKind.DeletedEntry;
}
}
diff --git a/src/Microsoft.AspNet.OData.Shared/EdmDeltaDeletedLink.cs b/src/Microsoft.AspNet.OData.Shared/EdmDeltaDeletedLink.cs
index ba64398e0d..bd12856bb3 100644
--- a/src/Microsoft.AspNet.OData.Shared/EdmDeltaDeletedLink.cs
+++ b/src/Microsoft.AspNet.OData.Shared/EdmDeltaDeletedLink.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Diagnostics.Contracts;
@@ -88,13 +92,12 @@ public string Relationship
}
///
- public EdmDeltaEntityKind DeltaKind
+ public override EdmDeltaEntityKind DeltaKind
{
get
- {
- Contract.Assert(_edmType != null);
- return _edmType.DeltaKind;
+ {
+ return EdmDeltaEntityKind.DeletedLinkEntry;
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/EdmDeltaEntityKind.cs b/src/Microsoft.AspNet.OData.Shared/EdmDeltaEntityKind.cs
index 627d3cc422..22b88ee658 100644
--- a/src/Microsoft.AspNet.OData.Shared/EdmDeltaEntityKind.cs
+++ b/src/Microsoft.AspNet.OData.Shared/EdmDeltaEntityKind.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
namespace Microsoft.AspNet.OData
{
@@ -33,4 +37,4 @@ public enum EdmDeltaEntityKind
///
Unknown = 4
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/EdmDeltaEntityObject.cs b/src/Microsoft.AspNet.OData.Shared/EdmDeltaEntityObject.cs
index 8c0d0bdd40..dcd7603af9 100644
--- a/src/Microsoft.AspNet.OData.Shared/EdmDeltaEntityObject.cs
+++ b/src/Microsoft.AspNet.OData.Shared/EdmDeltaEntityObject.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Diagnostics.Contracts;
@@ -47,12 +51,11 @@ public EdmDeltaEntityObject(IEdmEntityType entityType, bool isNullable)
}
///
- public EdmDeltaEntityKind DeltaKind
+ public override EdmDeltaEntityKind DeltaKind
{
get
{
- Contract.Assert(_edmType != null);
- return _edmType.DeltaKind;
+ return EdmDeltaEntityKind.Entry;
}
}
@@ -71,4 +74,4 @@ public IEdmNavigationSource NavigationSource
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/EdmDeltaLink.cs b/src/Microsoft.AspNet.OData.Shared/EdmDeltaLink.cs
index 75d750c7e9..d79a158407 100644
--- a/src/Microsoft.AspNet.OData.Shared/EdmDeltaLink.cs
+++ b/src/Microsoft.AspNet.OData.Shared/EdmDeltaLink.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Diagnostics.Contracts;
@@ -88,13 +92,12 @@ public string Relationship
}
///
- public EdmDeltaEntityKind DeltaKind
+ public override EdmDeltaEntityKind DeltaKind
{
get
- {
- Contract.Assert(_edmType != null);
- return _edmType.DeltaKind;
+ {
+ return EdmDeltaEntityKind.LinkEntry;
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/EdmDeltaType.cs b/src/Microsoft.AspNet.OData.Shared/EdmDeltaType.cs
index c787b3d3ae..56a567c3c4 100644
--- a/src/Microsoft.AspNet.OData.Shared/EdmDeltaType.cs
+++ b/src/Microsoft.AspNet.OData.Shared/EdmDeltaType.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Common;
using Microsoft.OData.Edm;
diff --git a/src/Microsoft.AspNet.OData.Shared/EdmEntityCollectionObject.cs b/src/Microsoft.AspNet.OData.Shared/EdmEntityCollectionObject.cs
index 5370a91bbe..43ac44c869 100644
--- a/src/Microsoft.AspNet.OData.Shared/EdmEntityCollectionObject.cs
+++ b/src/Microsoft.AspNet.OData.Shared/EdmEntityCollectionObject.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Collections.ObjectModel;
diff --git a/src/Microsoft.AspNet.OData.Shared/EdmEntityObject.cs b/src/Microsoft.AspNet.OData.Shared/EdmEntityObject.cs
index bd5cd4ccd0..fc092392cc 100644
--- a/src/Microsoft.AspNet.OData.Shared/EdmEntityObject.cs
+++ b/src/Microsoft.AspNet.OData.Shared/EdmEntityObject.cs
@@ -1,8 +1,17 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
+using System.Diagnostics.Contracts;
+using System.Reflection;
+using Microsoft.AspNet.OData.Builder;
+using Microsoft.AspNet.OData.Common;
using Microsoft.OData.Edm;
+using Org.OData.Core.V1;
namespace Microsoft.AspNet.OData
{
@@ -10,7 +19,7 @@ namespace Microsoft.AspNet.OData
/// Represents an with no backing CLR .
///
[NonValidatingParameterBinding]
- public class EdmEntityObject : EdmStructuredObject, IEdmEntityObject
+ public class EdmEntityObject : EdmStructuredObject, IEdmEntityObject, IEdmChangedObject
{
///
/// Initializes a new instance of the class.
@@ -37,7 +46,52 @@ public EdmEntityObject(IEdmEntityTypeReference edmType)
/// true if this object can be nullable; otherwise, false.
public EdmEntityObject(IEdmEntityType edmType, bool isNullable)
: base(edmType, isNullable)
+ {
+ PersistentInstanceAnnotationsContainer = new ODataInstanceAnnotationContainer();
+ TransientInstanceAnnotationContainer = new ODataInstanceAnnotationContainer();
+ }
+
+ ///
+ /// Instance Annotation container to hold Transient Annotations
+ ///
+ internal IODataInstanceAnnotationContainer TransientInstanceAnnotationContainer { get; set; }
+
+ ///
+ /// Instance Annotation container to hold Persistent Annotations
+ ///
+ public IODataInstanceAnnotationContainer PersistentInstanceAnnotationsContainer { get; set; }
+
+ ///
+ /// Container to hold ODataId
+ ///
+ public ODataIdContainer ODataIdContainer { get; set; }
+
+ ///
+ /// DeltaKind as Entry
+ ///
+ public virtual EdmDeltaEntityKind DeltaKind { get { return EdmDeltaEntityKind.Entry; } }
+
+ ///
+ /// Method to Add Data Modification Exception
+ ///
+ public void AddDataException(DataModificationExceptionType dataModificationException)
+ {
+ Contract.Assert(TransientInstanceAnnotationContainer != null);
+
+ TransientInstanceAnnotationContainer.AddResourceAnnotation(SRResources.DataModificationException, dataModificationException);
+ }
+
+ ///
+ /// Method to Add Data Modification Exception
+ ///
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
+ public DataModificationExceptionType GetDataException()
{
+ Contract.Assert(TransientInstanceAnnotationContainer != null);
+
+ DataModificationExceptionType dataModificationExceptionType = TransientInstanceAnnotationContainer.GetResourceAnnotation(SRResources.DataModificationException) as DataModificationExceptionType;
+
+ return dataModificationExceptionType;
}
}
}
diff --git a/src/Microsoft.AspNet.OData.Shared/EdmEnumObject.cs b/src/Microsoft.AspNet.OData.Shared/EdmEnumObject.cs
index bb32316e32..df4a3a6cff 100644
--- a/src/Microsoft.AspNet.OData.Shared/EdmEnumObject.cs
+++ b/src/Microsoft.AspNet.OData.Shared/EdmEnumObject.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Common;
@@ -68,4 +72,4 @@ public IEdmTypeReference GetEdmType()
return new EdmEnumTypeReference(_edmType as IEdmEnumType, IsNullable);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/EdmEnumObjectCollection.cs b/src/Microsoft.AspNet.OData.Shared/EdmEnumObjectCollection.cs
index ff7f8e0d7c..cdab9f1a66 100644
--- a/src/Microsoft.AspNet.OData.Shared/EdmEnumObjectCollection.cs
+++ b/src/Microsoft.AspNet.OData.Shared/EdmEnumObjectCollection.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Collections.ObjectModel;
diff --git a/src/Microsoft.AspNet.OData.Shared/EdmModelExtensions.cs b/src/Microsoft.AspNet.OData.Shared/EdmModelExtensions.cs
index 36e57f0678..02ef163879 100644
--- a/src/Microsoft.AspNet.OData.Shared/EdmModelExtensions.cs
+++ b/src/Microsoft.AspNet.OData.Shared/EdmModelExtensions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
diff --git a/src/Microsoft.AspNet.OData.Shared/EdmPatchMethodHandler.cs b/src/Microsoft.AspNet.OData.Shared/EdmPatchMethodHandler.cs
new file mode 100644
index 0000000000..08273149fd
--- /dev/null
+++ b/src/Microsoft.AspNet.OData.Shared/EdmPatchMethodHandler.cs
@@ -0,0 +1,54 @@
+using Microsoft.OData.Edm;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.Contracts;
+using System.Linq;
+using System.Linq.Expressions;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Microsoft.AspNet.OData
+{
+
+ ///
+ /// Handler Class to handle users methods for create, delete and update.
+ /// This is the handler for data modification where there is no CLR type.
+ ///
+ public abstract class EdmODataAPIHandler
+ {
+ ///
+ /// TryCreate method to create a new object.
+ ///
+ /// Changed object which can be appied on creted object, optional
+ /// The created object (Typeless)
+ /// Any error message in case of an exception
+ /// The status of the TryCreate Method, statuses are
+ public abstract ODataAPIResponseStatus TryCreate(IEdmChangedObject changedObject, out IEdmStructuredObject createdObject, out string errorMessage);
+
+ ///
+ /// TryGet method which tries to get the Origignal object based on a keyvalues.
+ ///
+ /// Key value pair for the entity keys
+ /// Object to return
+ /// Any error message in case of an exception
+ /// The status of the TryGet Method, statuses are
+ public abstract ODataAPIResponseStatus TryGet(IDictionary keyValues, out IEdmStructuredObject originalObject, out string errorMessage);
+
+ ///
+ /// TryDelete Method which will delete the object based on keyvalue pairs.
+ ///
+ ///
+ ///
+ /// The status of the TryDelete Method, statuses are
+ public abstract ODataAPIResponseStatus TryDelete(IDictionary keyValues, out string errorMessage);
+
+ ///
+ /// Get the API handler for the nested type
+ ///
+ /// Parent instance.
+ /// The name of the navigation property for the handler
+ /// Nested Patch Method handler for the navigation property
+ public abstract EdmODataAPIHandler GetNestedHandler(IEdmStructuredObject parent, string navigationPropertyName);
+ }
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/EdmStructuredObject.cs b/src/Microsoft.AspNet.OData.Shared/EdmStructuredObject.cs
index b902532bf2..094d3a5ecf 100644
--- a/src/Microsoft.AspNet.OData.Shared/EdmStructuredObject.cs
+++ b/src/Microsoft.AspNet.OData.Shared/EdmStructuredObject.cs
@@ -1,10 +1,15 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
+using System.Reflection;
using Microsoft.AspNet.OData.Common;
using Microsoft.AspNet.OData.Formatter;
using Microsoft.OData.Edm;
@@ -220,8 +225,15 @@ internal static object GetDefaultValue(IEdmTypeReference propertyType)
if (propertyType.IsPrimitive() ||
(isCollection && propertyType.AsCollection().ElementType().IsPrimitive()))
{
+
+ bool hasDefaultConstructor = (!clrType.IsClass) || clrType.GetConstructors(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static).
+ Any(x => x.GetParameters().Count() == 0);
+
// primitive or primitive collection
- return Activator.CreateInstance(clrType);
+ if (hasDefaultConstructor)
+ {
+ return Activator.CreateInstance(clrType);
+ }
}
else
{
diff --git a/src/Microsoft.AspNet.OData.Shared/EdmTypeExtensions.cs b/src/Microsoft.AspNet.OData.Shared/EdmTypeExtensions.cs
index cd4cb7c314..489d68f49c 100644
--- a/src/Microsoft.AspNet.OData.Shared/EdmTypeExtensions.cs
+++ b/src/Microsoft.AspNet.OData.Shared/EdmTypeExtensions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Common;
using Microsoft.OData.Edm;
@@ -22,7 +26,7 @@ public static bool IsDeltaFeed(this IEdmType type)
{
throw Error.ArgumentNull("type");
}
- return (type.GetType() == typeof(EdmDeltaCollectionType));
+ return (type.GetType() == typeof(EdmDeltaCollectionType)) || (type.GetType() == typeof(IDeltaSet));
}
///
@@ -39,4 +43,4 @@ public static bool IsDeltaResource(this IEdmObject resource)
return (resource is EdmDeltaEntityObject || resource is EdmDeltaComplexObject);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/EnableQueryAttribute.cs b/src/Microsoft.AspNet.OData.Shared/EnableQueryAttribute.cs
index c2cc1b0e04..4611156f19 100644
--- a/src/Microsoft.AspNet.OData.Shared/EnableQueryAttribute.cs
+++ b/src/Microsoft.AspNet.OData.Shared/EnableQueryAttribute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections;
@@ -611,7 +615,7 @@ private object ExecuteQuery(
{
IQueryable queryable = singleResultCollection as IQueryable;
queryable = ApplyQuery(queryable, queryOptions);
- return SingleOrDefault(queryable, actionDescriptor);
+ return QueryHelpers.SingleOrDefault(queryable, actionDescriptor);
}
}
else
@@ -676,44 +680,6 @@ internal static Type GetElementType(
return elementClrType;
}
- ///
- /// Get a single or default value from a collection.
- ///
- /// The response value as .
- /// The action context, i.e. action and controller name.
- ///
- internal static object SingleOrDefault(
- IQueryable queryable,
- IWebApiActionDescriptor actionDescriptor)
- {
- var enumerator = queryable.GetEnumerator();
- try
- {
- var result = enumerator.MoveNext() ? enumerator.Current : null;
-
- if (enumerator.MoveNext())
- {
- throw new InvalidOperationException(Error.Format(
- SRResources.SingleResultHasMoreThanOneEntity,
- actionDescriptor.ActionName,
- actionDescriptor.ControllerName,
- "SingleResult"));
- }
-
- return result;
- }
- finally
- {
- // Ensure any active/open database objects that were created
- // iterating over the IQueryable object are properly closed.
- var disposable = enumerator as IDisposable;
- if (disposable != null)
- {
- disposable.Dispose();
- }
- }
- }
-
///
/// Validate the select and expand options.
///
@@ -816,4 +782,4 @@ private static bool ContainsAutoSelectExpandProperty(
return false;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/ExpressionHelperMethods.cs b/src/Microsoft.AspNet.OData.Shared/ExpressionHelperMethods.cs
index d65c9c71f0..df5c027968 100644
--- a/src/Microsoft.AspNet.OData.Shared/ExpressionHelperMethods.cs
+++ b/src/Microsoft.AspNet.OData.Shared/ExpressionHelperMethods.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections;
@@ -111,6 +115,10 @@ internal class ExpressionHelperMethods
private static MethodInfo _safeConvertToDecimalMethod = typeof(ExpressionHelperMethods).GetMethod("SafeConvertToDecimal");
+#if NETCORE // Not supported in NETFX
+ private static MethodInfo _queryableCreateSingleResultMethod = GenericMethodOf(_ => SingleResult.Create(default(IQueryable)));
+#endif
+
public static MethodInfo EnumerableWhereGeneric
{
get { return _enumerableWhereMethod; }
@@ -366,6 +374,13 @@ public static MethodInfo CreateQueryGeneric
get { return _createQueryGenericMethod; }
}
+#if NETCORE // Not supported in NETFX
+ public static MethodInfo QueryableCreateSingleResult
+ {
+ get { return _queryableCreateSingleResultMethod; }
+ }
+#endif
+
public static decimal? SafeConvertToDecimal(object value)
{
if (value == null || value == DBNull.Value)
diff --git a/src/Microsoft.AspNet.OData.Shared/ExpressionHelpers.cs b/src/Microsoft.AspNet.OData.Shared/ExpressionHelpers.cs
index 72f8998037..99752d3d3e 100644
--- a/src/Microsoft.AspNet.OData.Shared/ExpressionHelpers.cs
+++ b/src/Microsoft.AspNet.OData.Shared/ExpressionHelpers.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Linq;
@@ -229,6 +233,12 @@ public static IQueryable SelectMany(IQueryable query, LambdaExpression expressio
return selectManyMethod.Invoke(null, new object[] { query, expression }) as IQueryable;
}
+ public static IQueryable SelectMany(IQueryable query, LambdaExpression expression, Type sourceType, Type resultType)
+ {
+ MethodInfo selectManyMethod = ExpressionHelperMethods.QueryableSelectManyGeneric.MakeGenericMethod(sourceType, resultType);
+ return selectManyMethod.Invoke(null, new object[] { query, expression }) as IQueryable;
+ }
+
public static IQueryable Aggregate(IQueryable query, object init, LambdaExpression sumLambda, Type type, Type wrapperType)
{
Type returnType = sumLambda.Body.Type;
@@ -276,5 +286,14 @@ public static LambdaExpression GetPropertyAccessLambda(Type type, string propert
MemberExpression propertyAccess = Expression.Property(odataItParameter, propertyName);
return Expression.Lambda(propertyAccess, odataItParameter);
}
+
+#if NETCORE // Not supported in NETFX
+
+ public static SingleResult CreateSingleResult(IQueryable query, Type type)
+ {
+ MethodInfo createSingleResultMethod = ExpressionHelperMethods.QueryableCreateSingleResult.MakeGenericMethod(type);
+ return createSingleResultMethod.Invoke(null, new[] { query }) as SingleResult;
+ }
+#endif
}
}
diff --git a/src/Microsoft.AspNet.OData.Shared/Extensions/ContainerBuilderExtensions.cs b/src/Microsoft.AspNet.OData.Shared/Extensions/ContainerBuilderExtensions.cs
index 6a6294fd2a..49053940c0 100644
--- a/src/Microsoft.AspNet.OData.Shared/Extensions/ContainerBuilderExtensions.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Extensions/ContainerBuilderExtensions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Diagnostics.CodeAnalysis;
diff --git a/src/Microsoft.AspNet.OData.Shared/FastPropertyAccessor.cs b/src/Microsoft.AspNet.OData.Shared/FastPropertyAccessor.cs
index 01791e3508..33926c685f 100644
--- a/src/Microsoft.AspNet.OData.Shared/FastPropertyAccessor.cs
+++ b/src/Microsoft.AspNet.OData.Shared/FastPropertyAccessor.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Reflection;
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/ClrTypeCache.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/ClrTypeCache.cs
index d70dce0751..b864c394b3 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/ClrTypeCache.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/ClrTypeCache.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Concurrent;
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/DefaultODataETagHandler.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/DefaultODataETagHandler.cs
index 9ffc54e96b..4a942faee5 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/DefaultODataETagHandler.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/DefaultODataETagHandler.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/CollectionDeserializationHelpers.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/CollectionDeserializationHelpers.cs
index 59bbccfc02..285f8b1f11 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/CollectionDeserializationHelpers.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/CollectionDeserializationHelpers.cs
@@ -1,9 +1,14 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Reflection;
@@ -115,10 +120,26 @@ public static void Clear(this IEnumerable collection, string propertyName, Type
clearMethod.Invoke(collection, _emptyObjectArray);
}
- public static bool TryCreateInstance(Type collectionType, IEdmCollectionTypeReference edmCollectionType, Type elementType, out IEnumerable instance)
+ public static bool TryCreateInstance(Type collectionType, IEdmCollectionTypeReference edmCollectionType, Type elementType, out IEnumerable instance, bool isDelta = false)
{
Contract.Assert(collectionType != null);
+ //For Delta Collection requests
+ if (isDelta)
+ {
+ if (elementType == typeof(IEdmEntityObject))
+ {
+ instance = new EdmChangedObjectCollection(edmCollectionType.ElementType().AsEntity().Definition as IEdmEntityType);
+ }
+ else
+ {
+ Type type = typeof(DeltaSet<>).MakeGenericType(elementType);
+ instance = Activator.CreateInstance(type, edmCollectionType.ElementType().AsEntity().Key().Select(x => x.Name).ToList()) as ICollection;
+ }
+
+ return true;
+ }
+
if (collectionType == typeof(EdmComplexObjectCollection))
{
instance = new EdmComplexObjectCollection(edmCollectionType);
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/DefaultODataDeserializerProvider.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/DefaultODataDeserializerProvider.cs
index cab4a6f838..b89f1355c9 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/DefaultODataDeserializerProvider.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/DefaultODataDeserializerProvider.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Common;
@@ -88,8 +92,6 @@ internal ODataDeserializer GetODataDeserializerImpl(Type type, Func m
return _rootContainer.GetRequiredService();
}
- // Get the model. Using a Func to delay evaluation of the model
- // until after the above checks have passed.
IEdmModel model = modelFunction();
ClrTypeCache typeMappingCache = model.GetTypeMappingCache();
IEdmTypeReference edmType = typeMappingCache.GetEdmType(type, model);
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/DeserializationHelpers.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/DeserializationHelpers.cs
index a50c4938fe..d0bb84036f 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/DeserializationHelpers.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/DeserializationHelpers.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections;
@@ -82,18 +86,82 @@ internal static void ApplyProperty(ODataProperty property, IEdmStructuredTypeRef
}
}
- internal static void ApplyInstanceAnnotations(object resource, IEdmStructuredTypeReference structuredType, ODataResource oDataResource,
+ internal static void ApplyInstanceAnnotations(object resource, IEdmStructuredTypeReference structuredType, ODataResourceBase oDataResource,
ODataDeserializerProvider deserializerProvider, ODataDeserializerContext readContext)
{
- PropertyInfo propertyInfo = EdmLibHelpers.GetInstanceAnnotationsContainer(structuredType.StructuredDefinition(), readContext.Model);
- if (propertyInfo == null)
+ //Apply instance annotations for both entityobject/changedobject/delta and normal resources
+
+ IODataInstanceAnnotationContainer instanceAnnotationContainer = null;
+ IODataInstanceAnnotationContainer transientAnnotationContainer = null;
+
+ EdmEntityObject edmObject = resource as EdmEntityObject;
+
+ if (edmObject != null)
+ {
+ instanceAnnotationContainer = edmObject.PersistentInstanceAnnotationsContainer;
+ transientAnnotationContainer = edmObject.TransientInstanceAnnotationContainer;
+ }
+ else
+ {
+ PropertyInfo propertyInfo = EdmLibHelpers.GetInstanceAnnotationsContainer(structuredType.StructuredDefinition(), readContext.Model);
+ if (propertyInfo != null)
+ {
+ instanceAnnotationContainer = GetAnnotationContainer(propertyInfo, resource);
+ }
+
+ IDeltaSetItem deltaItem = resource as IDeltaSetItem;
+
+ if (deltaItem != null)
+ {
+ transientAnnotationContainer = deltaItem.TransientInstanceAnnotationContainer;
+ }
+ }
+
+ if (instanceAnnotationContainer == null && transientAnnotationContainer == null)
{
return;
}
- IODataInstanceAnnotationContainer instanceAnnotationContainer = GetAnnotationContainer(propertyInfo, resource);
+ SetInstanceAnnotations(oDataResource, instanceAnnotationContainer, transientAnnotationContainer, deserializerProvider, readContext);
+ }
+
+ internal static void ApplyODataIdContainer(object resource, IEdmStructuredTypeReference structuredType, ODataResourceBase oDataResource,
+ ODataDeserializerProvider deserializerProvider, ODataDeserializerContext readContext)
+ {
+ //Apply instance annotations for both entityobject/changedobject/delta and normal resources
+
+ IODataInstanceAnnotationContainer instanceAnnotationContainer = null;
+ IODataInstanceAnnotationContainer transientAnnotationContainer = null;
+
+ EdmEntityObject edmObject = resource as EdmEntityObject;
+
+ if (edmObject != null)
+ {
+ instanceAnnotationContainer = edmObject.PersistentInstanceAnnotationsContainer;
+ transientAnnotationContainer = edmObject.TransientInstanceAnnotationContainer;
+ }
+ else
+ {
+ PropertyInfo propertyInfo = EdmLibHelpers.GetInstanceAnnotationsContainer(structuredType.StructuredDefinition(), readContext.Model);
+ if (propertyInfo != null)
+ {
+ instanceAnnotationContainer = GetAnnotationContainer(propertyInfo, resource);
+ }
+
+ IDeltaSetItem deltaItem = resource as IDeltaSetItem;
+
+ if (deltaItem != null)
+ {
+ transientAnnotationContainer = deltaItem.TransientInstanceAnnotationContainer;
+ }
+ }
+
+ if (instanceAnnotationContainer == null && transientAnnotationContainer == null)
+ {
+ return;
+ }
- SetInstanceAnnotations(oDataResource, instanceAnnotationContainer, deserializerProvider, readContext);
+ SetInstanceAnnotations(oDataResource, instanceAnnotationContainer, transientAnnotationContainer, deserializerProvider, readContext);
}
internal static void SetDynamicProperty(object resource, IEdmStructuredTypeReference resourceType,
@@ -135,15 +203,15 @@ internal static void SetDeclaredProperty(object resource, EdmTypeKind propertyKi
}
}
- internal static void SetCollectionProperty(object resource, IEdmProperty edmProperty, object value, string propertyName)
+ internal static void SetCollectionProperty(object resource, IEdmProperty edmProperty, object value, string propertyName, bool isDelta = false)
{
Contract.Assert(edmProperty != null);
- SetCollectionProperty(resource, propertyName, edmProperty.Type.AsCollection(), value, clearCollection: false);
+ SetCollectionProperty(resource, propertyName, edmProperty.Type.AsCollection(), value, clearCollection: false, isDelta);
}
internal static void SetCollectionProperty(object resource, string propertyName,
- IEdmCollectionTypeReference edmPropertyType, object value, bool clearCollection)
+ IEdmCollectionTypeReference edmPropertyType, object value, bool clearCollection, bool isDelta = false)
{
if (value != null)
{
@@ -163,7 +231,7 @@ internal static void SetCollectionProperty(object resource, string propertyName,
IEnumerable newCollection;
if (CanSetProperty(resource, propertyName) &&
- CollectionDeserializationHelpers.TryCreateInstance(propertyType, edmPropertyType, elementType, out newCollection))
+ CollectionDeserializationHelpers.TryCreateInstance(propertyType, edmPropertyType, elementType, out newCollection, isDelta))
{
// settable collections
collection.AddToCollection(newCollection, elementType, resourceType, propertyName, propertyType);
@@ -274,14 +342,21 @@ internal static void SetDynamicProperty(object resource, string propertyName, ob
}
}
- internal static void SetInstanceAnnotations(ODataResource oDataResource, IODataInstanceAnnotationContainer instanceAnnotationContainer,
- ODataDeserializerProvider deserializerProvider, ODataDeserializerContext readContext)
+ internal static void SetInstanceAnnotations(ODataResourceBase oDataResource, IODataInstanceAnnotationContainer instanceAnnotationContainer,
+ IODataInstanceAnnotationContainer transientAnnotationContainer, ODataDeserializerProvider deserializerProvider, ODataDeserializerContext readContext)
{
if(oDataResource.InstanceAnnotations != null)
{
foreach (ODataInstanceAnnotation annotation in oDataResource.InstanceAnnotations)
{
- AddInstanceAnnotationToContainer(instanceAnnotationContainer, deserializerProvider, readContext, annotation,string.Empty);
+ if (!TransientAnnotations.TransientAnnotationTerms.Contains(annotation.Name))
+ {
+ AddInstanceAnnotationToContainer(instanceAnnotationContainer, deserializerProvider, readContext, annotation, string.Empty);
+ }
+ else
+ {
+ AddInstanceAnnotationToContainer(transientAnnotationContainer, deserializerProvider, readContext, annotation, string.Empty);
+ }
}
}
@@ -313,11 +388,12 @@ private static void AddInstanceAnnotationToContainer(IODataInstanceAnnotationCon
instanceAnnotationContainer.AddPropertyAnnotation(propertyName,annotation.Name, annotationValue);
}
}
-
+
public static IODataInstanceAnnotationContainer GetAnnotationContainer(PropertyInfo propertyInfo, object resource)
- {
+ {
+ object value;
IDelta delta = resource as IDelta;
- object value;
+
if (delta != null)
{
delta.TryGetPropertyValue(propertyInfo.Name, out value);
@@ -325,7 +401,7 @@ public static IODataInstanceAnnotationContainer GetAnnotationContainer(PropertyI
else
{
value = propertyInfo.GetValue(resource);
- }
+ }
IODataInstanceAnnotationContainer instanceAnnotationContainer = value as IODataInstanceAnnotationContainer;
@@ -341,8 +417,8 @@ public static IODataInstanceAnnotationContainer GetAnnotationContainer(PropertyI
{
instanceAnnotationContainer = Activator.CreateInstance(propertyInfo.PropertyType) as IODataInstanceAnnotationContainer;
}
-
- if(delta != null)
+
+ if (delta != null)
{
delta.TrySetPropertyValue(propertyInfo.Name, instanceAnnotationContainer);
}
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/EnumDeserializationHelpers.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/EnumDeserializationHelpers.cs
index 88eccdbdcd..9c3fda6ba9 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/EnumDeserializationHelpers.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/EnumDeserializationHelpers.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.ComponentModel.DataAnnotations;
@@ -44,4 +48,4 @@ public static object ConvertEnumValue(object value, Type type)
return Enum.Parse(enumType, enumValue.Value);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataActionPayloadDeserializer.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataActionPayloadDeserializer.cs
index 870a178e16..737449aead 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataActionPayloadDeserializer.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataActionPayloadDeserializer.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections;
@@ -310,4 +314,4 @@ private static void ProcessResourceSet(object feed, IEdmCollectionTypeReference
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataCollectionDeserializer.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataCollectionDeserializer.cs
index 16bf33758f..3de3fabe08 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataCollectionDeserializer.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataCollectionDeserializer.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections;
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataDeltaResourceSetWrapper.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataDeltaResourceSetWrapper.cs
new file mode 100644
index 0000000000..daccf58009
--- /dev/null
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataDeltaResourceSetWrapper.cs
@@ -0,0 +1,26 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+
+using System.Collections.Generic;
+using Microsoft.OData;
+
+namespace Microsoft.AspNet.OData.Formatter.Deserialization
+{
+ ///
+ /// Encapsulates an and the 's that are part of it.
+ ///
+ public sealed class ODataDeltaResourceSetWrapper : ODataResourceSetWrapperBase
+ {
+ ///
+ /// Initializes a new instance of .
+ ///
+ /// The wrapped item.
+ public ODataDeltaResourceSetWrapper(ODataDeltaResourceSet item)
+ : base(item)
+ {
+
+ }
+
+ internal override ResourceSetType ResourceSetType => ResourceSetType.DeltaResourceSet;
+ }
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataDeserializer.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataDeserializer.cs
index fe90feb2c2..a167a088d7 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataDeserializer.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataDeserializer.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Threading.Tasks;
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataDeserializerContext.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataDeserializerContext.cs
index 494bfdfe6c..0dabf8e822 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataDeserializerContext.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataDeserializerContext.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Interfaces;
@@ -14,7 +18,11 @@ namespace Microsoft.AspNet.OData.Formatter.Deserialization
public partial class ODataDeserializerContext
{
private bool? _isDeltaOfT;
+ private bool? _isDeletedDeltaOfT;
private bool? _isUntyped;
+ private bool? _isChangedObjectCollection;
+ private bool? _isDeltaEntity;
+ private bool? _isDeltaDeletedEntity;
///
/// Gets or sets the type of the top-level object the request needs to be deserialized into.
@@ -58,20 +66,75 @@ internal bool IsDeltaOfT
{
if (!_isDeltaOfT.HasValue)
{
- _isDeltaOfT = ResourceType != null && TypeHelper.IsGenericType(ResourceType) && ResourceType.GetGenericTypeDefinition() == typeof(Delta<>);
+ _isDeltaOfT = ResourceType != null && TypeHelper.IsGenericType(ResourceType) && (ResourceType.GetGenericTypeDefinition() == typeof(Delta<>) ||
+ ResourceType.GetGenericTypeDefinition() == typeof(DeltaDeletedEntityObject<>));
}
return _isDeltaOfT.Value;
}
}
+ internal bool IsDeletedDeltaOfT
+ {
+ get
+ {
+ if (!_isDeletedDeltaOfT.HasValue)
+ {
+ _isDeletedDeltaOfT = ResourceType != null && TypeHelper.IsGenericType(ResourceType) && (ResourceType.GetGenericTypeDefinition() == typeof(DeltaDeletedEntityObject<>) ||
+ ResourceType.GetGenericTypeDefinition() == typeof(DeltaDeletedEntityObject<>));
+ }
+
+ return _isDeletedDeltaOfT.Value;
+ }
+ }
+
+ internal bool IsDeltaEntity
+ {
+ get
+ {
+ if (!_isDeltaEntity.HasValue)
+ {
+ _isDeltaEntity = ResourceType != null && (ResourceType == typeof(EdmDeltaEntityObject) || ResourceType == typeof(EdmDeltaDeletedEntityObject));
+ }
+
+ return _isDeltaEntity.Value;
+ }
+ }
+
+ internal bool IsDeltaDeletedEntity
+ {
+ get
+ {
+ if (!_isDeltaDeletedEntity.HasValue)
+ {
+ _isDeltaDeletedEntity = ResourceType != null && ResourceType == typeof(EdmDeltaDeletedEntityObject);
+ }
+
+ return _isDeltaDeletedEntity.Value;
+ }
+ }
+
+ internal bool IsChangedObjectCollection
+ {
+ get
+ {
+ if (!_isChangedObjectCollection.HasValue)
+ {
+ _isChangedObjectCollection = ResourceType != null && (ResourceType == typeof(EdmChangedObjectCollection) || (TypeHelper.IsGenericType(ResourceType) &&
+ ResourceType.GetGenericTypeDefinition() == typeof(DeltaSet<>) ));
+ }
+
+ return _isChangedObjectCollection.Value;
+ }
+ }
+
internal bool IsUntyped
{
get
{
if (!_isUntyped.HasValue)
{
- _isUntyped = TypeHelper.IsTypeAssignableFrom(typeof(IEdmObject), ResourceType) ||
+ _isUntyped = IsChangedObjectCollection ? !TypeHelper.IsGenericType(ResourceType) : (TypeHelper.IsTypeAssignableFrom(typeof(IEdmObject), ResourceType) && !IsDeltaOfT) ||
typeof(ODataUntypedActionParameters) == ResourceType;
}
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataDeserializerProvider.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataDeserializerProvider.cs
index 1a7e17a2b4..9e7c3ec021 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataDeserializerProvider.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataDeserializerProvider.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.OData.Edm;
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataEdmTypeDeserializer.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataEdmTypeDeserializer.cs
index 14a4c6f4bc..9a2d3cac9f 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataEdmTypeDeserializer.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataEdmTypeDeserializer.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Common;
using Microsoft.OData;
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataEntityReferenceLinkBase.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataEntityReferenceLinkBase.cs
index eff07d138a..ebbbf435f9 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataEntityReferenceLinkBase.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataEntityReferenceLinkBase.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.OData;
@@ -17,17 +21,13 @@ public class ODataEntityReferenceLinkBase : ODataItemBase
public ODataEntityReferenceLinkBase(ODataEntityReferenceLink item)
: base(item)
{
+ EntityReferenceLink = item;
}
///
/// Gets the wrapped .
///
- public ODataEntityReferenceLink EntityReferenceLink
- {
- get
- {
- return Item as ODataEntityReferenceLink;
- }
- }
+ public ODataEntityReferenceLink EntityReferenceLink { get; }
+
}
}
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataEntityReferenceLinkDeserializer.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataEntityReferenceLinkDeserializer.cs
index ecf6fb3446..0b92e4b23a 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataEntityReferenceLinkDeserializer.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataEntityReferenceLinkDeserializer.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataEnumDeserializer.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataEnumDeserializer.cs
index 061a0ae5a1..fb7a6b13ee 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataEnumDeserializer.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataEnumDeserializer.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Diagnostics.Contracts;
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataItemBase.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataItemBase.cs
index 8860176bbe..25f6805f67 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataItemBase.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataItemBase.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.OData;
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataNestedResourceInfoWrapper.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataNestedResourceInfoWrapper.cs
index 5dc286af5a..1793290957 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataNestedResourceInfoWrapper.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataNestedResourceInfoWrapper.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using Microsoft.OData;
@@ -40,5 +44,6 @@ public ODataNestedResourceInfo NestedResourceInfo
/// Gets the nested items that are part of this nested resource info.
///
public IList NestedItems { get; private set; }
+
}
}
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataPrimitiveDeserializer.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataPrimitiveDeserializer.cs
index cddfbb4ea1..af3e8d78f0 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataPrimitiveDeserializer.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataPrimitiveDeserializer.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Diagnostics.Contracts;
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataReaderExtensions.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataReaderExtensions.cs
index e86b4bcf3a..a7d1d069b7 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataReaderExtensions.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataReaderExtensions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Diagnostics.Contracts;
@@ -85,30 +89,31 @@ private static void ReadCollectionItem(ODataReader reader, Stack
}
else
{
- ODataItemBase parentItem = itemsStack.Peek();
- ODataResourceSetWrapper parentResourceSet = parentItem as ODataResourceSetWrapper;
- if (parentResourceSet != null)
- {
- parentResourceSet.Resources.Add(resourceWrapper);
- }
- else
- {
- ODataNestedResourceInfoWrapper parentNestedResource = (ODataNestedResourceInfoWrapper)parentItem;
- Contract.Assert(parentNestedResource.NestedResourceInfo.IsCollection == false, "Only singleton nested properties can contain resource as their child.");
- Contract.Assert(parentNestedResource.NestedItems.Count == 0, "Each nested property can contain only one resource as its direct child.");
- parentNestedResource.NestedItems.Add(resourceWrapper);
- }
+ AddResourceToParent(itemsStack, resourceWrapper);
}
itemsStack.Push(resourceWrapper);
break;
case ODataReaderState.ResourceEnd:
+ case ODataReaderState.DeletedResourceEnd:
Contract.Assert(
itemsStack.Count > 0 && (reader.Item == null || itemsStack.Peek().Item == reader.Item),
"The resource which is ending should be on the top of the items stack.");
itemsStack.Pop();
break;
+ case ODataReaderState.DeletedResourceStart:
+ ODataDeletedResource deletedResource = (ODataDeletedResource)reader.Item;
+ Contract.Assert(deletedResource != null, "Deleted resource should not be null");
+
+ ODataResourceWrapper deletedResourceWrapper = new ODataResourceWrapper(deletedResource);
+
+ Contract.Assert(itemsStack.Count != 0, "Deleted Resource should not be top level item");
+
+ AddResourceToParent(itemsStack, deletedResourceWrapper);
+
+ itemsStack.Push(deletedResourceWrapper);
+ break;
case ODataReaderState.NestedResourceInfoStart:
ODataNestedResourceInfo nestedResourceInfo = (ODataNestedResourceInfo)reader.Item;
@@ -135,12 +140,10 @@ private static void ReadCollectionItem(ODataReader reader, Stack
Contract.Assert(resourceSet != null, "ResourceSet should never be null.");
ODataResourceSetWrapper resourceSetWrapper = new ODataResourceSetWrapper(resourceSet);
+
if (itemsStack.Count > 0)
{
- ODataNestedResourceInfoWrapper parentNestedResourceInfo = (ODataNestedResourceInfoWrapper)itemsStack.Peek();
- Contract.Assert(parentNestedResourceInfo != null, "this has to be an inner resource set. inner resource sets always have a nested resource info.");
- Contract.Assert(parentNestedResourceInfo.NestedResourceInfo.IsCollection == true, "Only collection nested properties can contain resource set as their child.");
- parentNestedResourceInfo.NestedItems.Add(resourceSetWrapper);
+ AddNestedResourceInfo(itemsStack, resourceSetWrapper);
}
else
{
@@ -151,6 +154,7 @@ private static void ReadCollectionItem(ODataReader reader, Stack
break;
case ODataReaderState.ResourceSetEnd:
+ case ODataReaderState.DeltaResourceSetEnd:
Contract.Assert(itemsStack.Count > 0 && itemsStack.Peek().Item == reader.Item, "The resource set which is ending should be on the top of the items stack.");
itemsStack.Pop();
break;
@@ -167,11 +171,58 @@ private static void ReadCollectionItem(ODataReader reader, Stack
}
break;
+ case ODataReaderState.DeltaResourceSetStart:
+ ODataDeltaResourceSet deltaResourceSet = (ODataDeltaResourceSet)reader.Item;
+ Contract.Assert(deltaResourceSet != null, "ResourceSet should never be null.");
+
+ ODataDeltaResourceSetWrapper deltaResourceSetWrapper = new ODataDeltaResourceSetWrapper(deltaResourceSet);
+
+ if (itemsStack.Count > 0)
+ {
+ AddNestedResourceInfo(itemsStack, deltaResourceSetWrapper);
+ }
+ else
+ {
+ topLevelItem = deltaResourceSetWrapper;
+ }
+
+ itemsStack.Push(deltaResourceSetWrapper);
+ break;
+ case ODataReaderState.DeltaLink:
+ case ODataReaderState.DeltaDeletedLink:
+
+ //Throw error if Delta Link appears
+ throw Error.NotSupported(SRResources.DeltaLinkNotSupported);
+
default:
Contract.Assert(false, "We should never get here, it means the ODataReader reported a wrong state.");
break;
}
}
+
+
+ private static void AddNestedResourceInfo(Stack itemsStack, ODataResourceSetWrapperBase resourceSetWrapper)
+ {
+ ODataNestedResourceInfoWrapper parentNestedResourceInfo = (ODataNestedResourceInfoWrapper)itemsStack.Peek();
+ Contract.Assert(parentNestedResourceInfo != null, "this has to be an inner resource set. inner resource sets always have a nested resource info.");
+ Contract.Assert(parentNestedResourceInfo.NestedResourceInfo.IsCollection == true, "Only collection nested properties can contain resource set as their child.");
+ parentNestedResourceInfo.NestedItems.Add(resourceSetWrapper);
+ }
+
+ private static void AddResourceToParent(Stack itemsStack, ODataResourceWrapper resourceWrapper)
+ {
+ ODataItemBase parentItem = itemsStack.Peek();
+ ODataResourceSetWrapperBase parentResourceSet = parentItem as ODataResourceSetWrapperBase;
+ if (parentResourceSet != null)
+ {
+ parentResourceSet.Resources.Add(resourceWrapper);
+ }
+ else
+ {
+ ODataNestedResourceInfoWrapper parentNestedResource = (ODataNestedResourceInfoWrapper)parentItem;
+ parentNestedResource.NestedItems.Add(resourceWrapper);
+ }
+ }
}
}
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataResourceDeserializer.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataResourceDeserializer.cs
index 290b21771b..ab8ca077b7 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataResourceDeserializer.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataResourceDeserializer.cs
@@ -1,9 +1,14 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Reflection;
@@ -11,15 +16,19 @@
using System.Runtime.Serialization;
using System.Threading.Tasks;
using Microsoft.AspNet.OData.Common;
-using Microsoft.AspNet.OData.Formatter.Serialization;
+using Microsoft.AspNet.OData.Interfaces;
+using Microsoft.AspNet.OData.Routing;
using Microsoft.OData;
using Microsoft.OData.Edm;
+using Microsoft.OData.UriParser;
+using ODataPath = Microsoft.AspNet.OData.Routing.ODataPath;
namespace Microsoft.AspNet.OData.Formatter.Deserialization
{
///
/// Represents an for reading OData resource payloads.
///
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling")]
public class ODataResourceDeserializer : ODataEdmTypeDeserializer
{
///
@@ -96,6 +105,7 @@ public sealed override object ReadInline(object item, IEdmTypeReference edmType,
// Recursion guard to avoid stack overflows
RuntimeHelpers.EnsureSufficientExecutionStack();
+ resourceWrapper = UpdateResourceWrapper(resourceWrapper, readContext);
return ReadResource(resourceWrapper, edmType.AsStructured(), readContext);
}
@@ -119,8 +129,9 @@ public virtual object ReadResource(ODataResourceWrapper resourceWrapper, IEdmStr
{
throw Error.ArgumentNull("readContext");
}
+
- if (!String.IsNullOrEmpty(resourceWrapper.Resource.TypeName) && structuredType.FullName() != resourceWrapper.Resource.TypeName)
+ if (!String.IsNullOrEmpty(resourceWrapper.ResourceBase.TypeName) && structuredType.FullName() != resourceWrapper.ResourceBase.TypeName)
{
// received a derived type in a base type deserializer. delegate it to the appropriate derived type deserializer.
IEdmModel model = readContext.Model;
@@ -130,20 +141,21 @@ public virtual object ReadResource(ODataResourceWrapper resourceWrapper, IEdmStr
throw Error.Argument("readContext", SRResources.ModelMissingFromReadContext);
}
- IEdmStructuredType actualType = model.FindType(resourceWrapper.Resource.TypeName) as IEdmStructuredType;
+ IEdmStructuredType actualType = model.FindType(resourceWrapper.ResourceBase.TypeName) as IEdmStructuredType;
if (actualType == null)
{
- throw new ODataException(Error.Format(SRResources.ResourceTypeNotInModel, resourceWrapper.Resource.TypeName));
+ throw new ODataException(Error.Format(SRResources.ResourceTypeNotInModel, resourceWrapper.ResourceBase.TypeName));
}
if (actualType.IsAbstract)
{
- string message = Error.Format(SRResources.CannotInstantiateAbstractResourceType, resourceWrapper.Resource.TypeName);
+ string message = Error.Format(SRResources.CannotInstantiateAbstractResourceType, resourceWrapper.ResourceBase.TypeName);
throw new ODataException(message);
}
IEdmTypeReference actualStructuredType;
IEdmEntityType actualEntityType = actualType as IEdmEntityType;
+
if (actualEntityType != null)
{
actualStructuredType = new EdmEntityTypeReference(actualEntityType, isNullable: false);
@@ -174,10 +186,19 @@ public virtual object ReadResource(ODataResourceWrapper resourceWrapper, IEdmStr
{
object resource = CreateResourceInstance(structuredType, readContext);
ApplyResourceProperties(resource, resourceWrapper, structuredType, readContext);
+
+ ODataDeletedResource deletedResource = resourceWrapper.ResourceBase as ODataDeletedResource;
+
+ if (deletedResource != null)
+ {
+ AppendDeletedProperties(resource, deletedResource, readContext.IsUntyped);
+ }
+
return resource;
}
}
+
///
/// Creates a new instance of the backing CLR object for the given resource type.
///
@@ -206,6 +227,11 @@ public virtual object CreateResourceInstance(IEdmStructuredTypeReference structu
{
if (structuredType.IsEntity())
{
+ if (readContext.IsDeltaDeletedEntity)
+ {
+ return new EdmDeltaDeletedEntityObject(structuredType.AsEntity());
+ }
+
return new EdmEntityObject(structuredType.AsEntity());
}
@@ -222,8 +248,11 @@ public virtual object CreateResourceInstance(IEdmStructuredTypeReference structu
if (readContext.IsDeltaOfT)
{
- IEnumerable structuralProperties = structuredType.StructuralProperties()
+ IEnumerable structuralProperties = structuredType.StructuredDefinition().Properties()
.Select(edmProperty => EdmLibHelpers.GetClrPropertyName(edmProperty, model));
+
+ PropertyInfo instanceAnnotationProperty = EdmLibHelpers.GetInstanceAnnotationsContainer(
+ structuredType.StructuredDefinition(), model);
if (structuredType.IsOpen())
{
@@ -231,11 +260,11 @@ public virtual object CreateResourceInstance(IEdmStructuredTypeReference structu
structuredType.StructuredDefinition(), model);
return Activator.CreateInstance(readContext.ResourceType, clrType, structuralProperties,
- dynamicDictionaryPropertyInfo);
+ dynamicDictionaryPropertyInfo, instanceAnnotationProperty);
}
else
{
- return Activator.CreateInstance(readContext.ResourceType, clrType, structuralProperties);
+ return Activator.CreateInstance(readContext.ResourceType, clrType, structuralProperties, null, instanceAnnotationProperty);
}
}
else
@@ -245,6 +274,20 @@ public virtual object CreateResourceInstance(IEdmStructuredTypeReference structu
}
}
+ private static void AppendDeletedProperties(dynamic resource, ODataDeletedResource deletedResource, bool isUntyped)
+ {
+ if (isUntyped)
+ {
+ resource.Id = deletedResource.Id.ToString();
+ }
+ else
+ {
+ resource.Id = deletedResource.Id;
+ }
+
+ resource.Reason = deletedResource.Reason.Value;
+ }
+
///
/// Deserializes the nested properties from into .
///
@@ -297,7 +340,39 @@ public virtual void ApplyNestedProperty(object resource, ODataNestedResourceInfo
}
}
- foreach (ODataItemBase childItem in resourceInfoWrapper.NestedItems)
+ IList nestedItems;
+ ODataEntityReferenceLinkBase[] referenceLinks = resourceInfoWrapper.NestedItems.OfType().ToArray();
+ if (referenceLinks.Length > 0)
+ {
+ // Be noted:
+ // 1) OData v4.0, it's "Orders@odata.bind", and we get "ODataEntityReferenceLinkWrapper"(s) for that.
+ // 2) OData v4.01, it's {"odata.id" ...}, and we get "ODataResource"(s) for that.
+ // So, in OData v4, if it's a single, NestedItems contains one ODataEntityReferenceLinkWrapper,
+ // if it's a collection, NestedItems contains multiple ODataEntityReferenceLinkWrapper(s)
+ // We can use the following code to adjust the `ODataEntityReferenceLinkWrapper` to `ODataResourceWrapper`.
+ // In OData v4.01, we will not be here.
+ // Only supports declared property
+ Contract.Assert(edmProperty != null);
+
+ nestedItems = new List();
+ if (edmProperty.Type.IsCollection())
+ {
+ IEdmCollectionTypeReference edmCollectionTypeReference = edmProperty.Type.AsCollection();
+ ODataResourceSetWrapper resourceSetWrapper = CreateResourceSetWrapper(edmCollectionTypeReference, referenceLinks, readContext);
+ nestedItems.Add(resourceSetWrapper);
+ }
+ else
+ {
+ ODataResourceWrapper resourceWrapper = CreateResourceWrapper(edmProperty.Type, referenceLinks[0], readContext);
+ nestedItems.Add(resourceWrapper);
+ }
+ }
+ else
+ {
+ nestedItems = resourceInfoWrapper.NestedItems;
+ }
+
+ foreach (ODataItemBase childItem in nestedItems)
{
// it maybe null.
if (childItem == null)
@@ -313,15 +388,8 @@ public virtual void ApplyNestedProperty(object resource, ODataNestedResourceInfo
ApplyResourceInNestedProperty(edmProperty, resource, null, readContext);
}
}
-
- ODataEntityReferenceLinkBase entityReferenceLink = childItem as ODataEntityReferenceLinkBase;
- if (entityReferenceLink != null)
- {
- // ignore entity reference links.
- continue;
- }
-
- ODataResourceSetWrapper resourceSetWrapper = childItem as ODataResourceSetWrapper;
+
+ ODataResourceSetWrapperBase resourceSetWrapper = childItem as ODataResourceSetWrapperBase;
if (resourceSetWrapper != null)
{
if (edmProperty == null)
@@ -354,6 +422,188 @@ public virtual void ApplyNestedProperty(object resource, ODataNestedResourceInfo
}
}
+
+ private ODataResourceSetWrapper CreateResourceSetWrapper(IEdmCollectionTypeReference edmPropertyType,
+ IList refLinks, ODataDeserializerContext readContext)
+ {
+ ODataResourceSet resourceSet = new ODataResourceSet
+ {
+ TypeName = edmPropertyType.FullName(),
+ };
+
+ IEdmTypeReference elementType = edmPropertyType.ElementType();
+ ODataResourceSetWrapper resourceSetWrapper = new ODataResourceSetWrapper(resourceSet);
+ foreach (ODataEntityReferenceLinkBase refLinkWrapper in refLinks)
+ {
+ ODataResourceWrapper resourceWrapper = CreateResourceWrapper(elementType, refLinkWrapper, readContext);
+ resourceSetWrapper.Resources.Add(resourceWrapper);
+ }
+
+ return resourceSetWrapper;
+ }
+
+ private ODataResourceWrapper CreateResourceWrapper(IEdmTypeReference edmPropertyType, ODataEntityReferenceLinkBase refLink, ODataDeserializerContext readContext)
+ {
+ Contract.Assert(readContext != null);
+
+ ODataResource resource = new ODataResource
+ {
+ TypeName = edmPropertyType.FullName(),
+ };
+
+ resource.Properties = CreateKeyProperties(refLink.EntityReferenceLink.Url, readContext);
+
+ if (refLink.EntityReferenceLink.InstanceAnnotations != null)
+ {
+ foreach (ODataInstanceAnnotation instanceAnnotation in refLink.EntityReferenceLink.InstanceAnnotations)
+ {
+ resource.InstanceAnnotations.Add(instanceAnnotation);
+ };
+ }
+
+ return new ODataResourceWrapper(resource);
+ }
+
+ ///
+ /// Update the resource wrapper if it has the "Id" value.
+ ///
+ /// The resource wrapper.
+ /// The read context.
+ /// The resource wrapper.
+ private ODataResourceWrapper UpdateResourceWrapper(ODataResourceWrapper resourceWrapper, ODataDeserializerContext readContext)
+ {
+ Contract.Assert(readContext != null);
+
+ if (resourceWrapper?.ResourceBase?.Id == null)
+ {
+ return resourceWrapper;
+ }
+
+ IEnumerable keys = CreateKeyProperties(resourceWrapper.ResourceBase.Id, readContext);
+ if (keys == null)
+ {
+ return resourceWrapper;
+ }
+
+ if (resourceWrapper.ResourceBase.Properties == null)
+ {
+ resourceWrapper.ResourceBase.Properties = keys;
+ }
+ else
+ {
+ IDictionary newPropertiesDic = resourceWrapper.ResourceBase.Properties.ToDictionary(p => p.Name, p => p);
+ foreach (ODataProperty key in keys)
+ {
+ if (!newPropertiesDic.ContainsKey(key.Name))
+ {
+ newPropertiesDic[key.Name] = key;
+ }
+ }
+
+ resourceWrapper.ResourceBase.Properties = newPropertiesDic.Values;
+ }
+
+ return resourceWrapper;
+ }
+
+ ///
+ /// Do uri parsing to get the key values.
+ ///
+ /// The key Id.
+ /// The reader context.
+ /// The key properties.
+ private static IList CreateKeyProperties(Uri id, ODataDeserializerContext readContext)
+ {
+ Contract.Assert(id != null);
+ Contract.Assert(readContext != null);
+ IList properties = new List();
+ if (readContext.Request == null)
+ {
+ return properties;
+ }
+
+ ODataPath odataPath = GetODataPath(id.OriginalString, readContext);
+ if (odataPath?.Segments != null)
+ {
+ KeySegment keySegment = odataPath.Segments.OfType().LastOrDefault();
+
+ if (keySegment != null)
+ {
+ foreach (KeyValuePair key in keySegment.Keys)
+ {
+ properties.Add(new ODataProperty
+ {
+ Name = key.Key,
+ Value = key.Value
+ });
+ }
+ }
+ }
+
+ return properties;
+ }
+
+ private static ODataPath GetODataPath(string id, ODataDeserializerContext readContext)
+ {
+ try
+ {
+ IODataPathHandler pathHandler = readContext.InternalRequest.PathHandler;
+ IWebApiRequestMessage internalRequest = readContext.InternalRequest;
+ IWebApiUrlHelper urlHelper = readContext.InternalUrlHelper;
+
+ string serviceRoot = urlHelper.CreateODataLink(
+ internalRequest.Context.RouteName,
+ internalRequest.PathHandler,
+ new List());
+ ODataPath odataPath = pathHandler.Parse(serviceRoot, id, internalRequest.RequestContainer);
+
+
+ return odataPath;
+ }
+ catch (Exception)
+ {
+ return null;
+ }
+ }
+
+ private static void ApplyODataIDContainer(object resource, ODataResourceWrapper resourceWrapper,
+ ODataDeserializerContext readContext)
+ {
+ //Setting Odataid , for POCO classes, as a property in the POCO object itself(if user has OdataIDContainer property),
+ //for Delta and EdmEntity object setting as an added property ODataIdcontianer in those classes
+ if (resourceWrapper.ResourceBase?.Id != null)
+ {
+ string odataId = resourceWrapper.ResourceBase.Id.OriginalString;
+
+ ODataPath odataPath = GetODataPath(odataId, readContext);
+
+ if (odataPath != null)
+ {
+ ODataIdContainer container = new ODataIdContainer();
+
+ NavigationPath navigationPath = new NavigationPath(odataId, odataPath.Segments);
+ container.ODataIdNavigationPath = navigationPath;
+
+ if (resource is EdmEntityObject edmObject)
+ {
+ edmObject.ODataIdContainer = container;
+ }
+ else if (resource is IDeltaSetItem deltasetItem)
+ {
+ deltasetItem.ODataIdContainer = container;
+ }
+ else
+ {
+ PropertyInfo containerPropertyInfo = EdmLibHelpers.GetClrType(odataPath.EdmType, readContext.Model).GetProperties().Where(x => x.PropertyType == typeof(ODataIdContainer)).FirstOrDefault();
+ if (containerPropertyInfo != null)
+ {
+ containerPropertyInfo.SetValue(resource, container);
+ }
+ }
+ }
+ }
+ }
+
///
/// Deserializes the structural properties from into .
///
@@ -369,7 +619,7 @@ public virtual void ApplyStructuralProperties(object resource, ODataResourceWrap
throw Error.ArgumentNull("resourceWrapper");
}
- foreach (ODataProperty property in resourceWrapper.Resource.Properties)
+ foreach (ODataProperty property in resourceWrapper.ResourceBase.Properties)
{
ApplyStructuralProperty(resource, property, structuredType, readContext);
}
@@ -390,7 +640,7 @@ public virtual void ApplyInstanceAnnotations(object resource, ODataResourceWrapp
throw Error.ArgumentNull("resourceWrapper");
}
- DeserializationHelpers.ApplyInstanceAnnotations(resource, structuredType, resourceWrapper.Resource,DeserializerProvider, readContext);
+ DeserializationHelpers.ApplyInstanceAnnotations(resource, structuredType, resourceWrapper.ResourceBase,DeserializerProvider, readContext);
}
///
@@ -418,10 +668,12 @@ public virtual void ApplyStructuralProperty(object resource, ODataProperty struc
private void ApplyResourceProperties(object resource, ODataResourceWrapper resourceWrapper,
IEdmStructuredTypeReference structuredType, ODataDeserializerContext readContext)
+
{
ApplyStructuralProperties(resource, resourceWrapper, structuredType, readContext);
ApplyNestedProperties(resource, resourceWrapper, structuredType, readContext);
ApplyInstanceAnnotations(resource, resourceWrapper, structuredType, readContext);
+ ApplyODataIDContainer(resource, resourceWrapper, readContext);
}
private void ApplyResourceInNestedProperty(IEdmProperty nestedProperty, object resource,
@@ -431,19 +683,8 @@ private void ApplyResourceInNestedProperty(IEdmProperty nestedProperty, object r
Contract.Assert(resource != null);
Contract.Assert(readContext != null);
- if (readContext.IsDeltaOfT)
- {
- IEdmNavigationProperty navigationProperty = nestedProperty as IEdmNavigationProperty;
- if (navigationProperty != null)
- {
- string message = Error.Format(SRResources.CannotPatchNavigationProperties, navigationProperty.Name,
- navigationProperty.DeclaringEntityType().FullName());
- throw new ODataException(message);
- }
- }
-
object value = ReadNestedResourceInline(resourceWrapper, nestedProperty.Type, readContext);
-
+
// First resolve Data member alias or annotation, then set the regular
// or delta resource accordingly.
string propertyName = EdmLibHelpers.GetClrPropertyName(nestedProperty, readContext.Model);
@@ -460,7 +701,7 @@ private void ApplyDynamicResourceInNestedProperty(string propertyName, object re
object value = null;
if (resourceWrapper != null)
{
- IEdmSchemaType elementType = readContext.Model.FindDeclaredType(resourceWrapper.Resource.TypeName);
+ IEdmSchemaType elementType = readContext.Model.FindDeclaredType(resourceWrapper.ResourceBase.TypeName);
IEdmTypeReference edmTypeReference = elementType.ToEdmTypeReference(true);
value = ReadNestedResourceInline(resourceWrapper, edmTypeReference, readContext);
@@ -492,14 +733,14 @@ private object ReadNestedResourceInline(ODataResourceWrapper resourceWrapper, IE
{
Path = readContext.Path,
Model = readContext.Model,
- Request = readContext.Request,
+ Request = readContext.Request
};
Type clrType = null;
if (readContext.IsUntyped)
{
clrType = structuredType.IsEntity()
- ? typeof(EdmEntityObject)
+ ? (readContext.IsDeltaEntity ? (readContext.IsDeltaDeletedEntity? typeof(EdmDeltaDeletedEntityObject) : typeof(EdmDeltaEntityObject) ) : typeof(EdmEntityObject))
: typeof(EdmComplexObject);
}
else
@@ -518,45 +759,33 @@ private object ReadNestedResourceInline(ODataResourceWrapper resourceWrapper, IE
: clrType;
return deserializer.ReadInline(resourceWrapper, edmType, nestedReadContext);
}
-
private void ApplyResourceSetInNestedProperty(IEdmProperty nestedProperty, object resource,
- ODataResourceSetWrapper resourceSetWrapper, ODataDeserializerContext readContext)
+ ODataResourceSetWrapperBase resourceSetWrapper, ODataDeserializerContext readContext)
{
Contract.Assert(nestedProperty != null);
Contract.Assert(resource != null);
Contract.Assert(readContext != null);
- if (readContext.IsDeltaOfT)
- {
- IEdmNavigationProperty navigationProperty = nestedProperty as IEdmNavigationProperty;
- if (navigationProperty != null)
- {
- string message = Error.Format(SRResources.CannotPatchNavigationProperties, navigationProperty.Name,
- navigationProperty.DeclaringEntityType().FullName());
- throw new ODataException(message);
- }
- }
-
object value = ReadNestedResourceSetInline(resourceSetWrapper, nestedProperty.Type, readContext);
string propertyName = EdmLibHelpers.GetClrPropertyName(nestedProperty, readContext.Model);
- DeserializationHelpers.SetCollectionProperty(resource, nestedProperty, value, propertyName);
+ DeserializationHelpers.SetCollectionProperty(resource, nestedProperty, value, propertyName, resourceSetWrapper.ResourceSetType == ResourceSetType.DeltaResourceSet);
}
private void ApplyDynamicResourceSetInNestedProperty(string propertyName, object resource, IEdmStructuredTypeReference structuredType,
- ODataResourceSetWrapper resourceSetWrapper, ODataDeserializerContext readContext)
+ ODataResourceSetWrapperBase resourceSetWrapper, ODataDeserializerContext readContext)
{
Contract.Assert(resource != null);
Contract.Assert(readContext != null);
- if (String.IsNullOrEmpty(resourceSetWrapper.ResourceSet.TypeName))
+ if (String.IsNullOrEmpty(resourceSetWrapper.ResourceSetBase.TypeName))
{
string message = Error.Format(SRResources.DynamicResourceSetTypeNameIsRequired, propertyName);
throw new ODataException(message);
}
string elementTypeName =
- DeserializationHelpers.GetCollectionElementTypeName(resourceSetWrapper.ResourceSet.TypeName,
+ DeserializationHelpers.GetCollectionElementTypeName(resourceSetWrapper.ResourceSetBase.TypeName,
isNested: false);
IEdmSchemaType elementType = readContext.Model.FindDeclaredType(elementTypeName);
@@ -583,7 +812,7 @@ private void ApplyDynamicResourceSetInNestedProperty(string propertyName, object
result, collectionType, readContext.Model);
}
- private object ReadNestedResourceSetInline(ODataResourceSetWrapper resourceSetWrapper, IEdmTypeReference edmType,
+ private object ReadNestedResourceSetInline(ODataResourceSetWrapperBase resourceSetWrapper, IEdmTypeReference edmType,
ODataDeserializerContext readContext)
{
Contract.Assert(resourceSetWrapper != null);
@@ -601,14 +830,15 @@ private object ReadNestedResourceSetInline(ODataResourceSetWrapper resourceSetWr
{
Path = readContext.Path,
Model = readContext.Model,
- Request = readContext.Request,
+ Request = readContext.Request
};
if (readContext.IsUntyped)
{
if (structuredType.IsEntity())
{
- nestedReadContext.ResourceType = typeof(EdmEntityObjectCollection);
+ nestedReadContext.ResourceType = (readContext.IsDeltaOfT && resourceSetWrapper.ResourceSetType == ResourceSetType.DeltaResourceSet)?
+ typeof(EdmChangedObjectCollection): typeof(EdmEntityObjectCollection);
}
else
{
@@ -625,7 +855,8 @@ private object ReadNestedResourceSetInline(ODataResourceSetWrapper resourceSetWr
Error.Format(SRResources.MappingDoesNotContainResourceType, structuredType.FullName()));
}
- nestedReadContext.ResourceType = typeof(List<>).MakeGenericType(clrType);
+ nestedReadContext.ResourceType = (readContext.IsDeltaOfT && resourceSetWrapper.ResourceSetType == ResourceSetType.DeltaResourceSet)
+ ? typeof(DeltaSet<>).MakeGenericType(clrType) : typeof(List<>).MakeGenericType(clrType);
}
return deserializer.ReadInline(resourceSetWrapper, edmType, nestedReadContext);
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataResourceSetDeserializer.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataResourceSetDeserializer.cs
index b0d180f590..27aa8972e8 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataResourceSetDeserializer.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataResourceSetDeserializer.cs
@@ -1,8 +1,14 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Reflection;
@@ -48,7 +54,7 @@ public override object Read(ODataMessageReader messageReader, Type type, ODataDe
throw Error.Argument("edmType", SRResources.ArgumentMustBeOfType, EdmTypeKind.Complex + " or " + EdmTypeKind.Entity);
}
- ODataReader resourceSetReader = messageReader.CreateODataResourceSetReader();
+ ODataReader resourceSetReader = readContext.IsChangedObjectCollection ? messageReader.CreateODataDeltaResourceSetReader() : messageReader.CreateODataResourceSetReader();
object resourceSet = resourceSetReader.ReadResourceOrResourceSet();
return ReadInline(resourceSet, edmType, readContext);
}
@@ -70,12 +76,13 @@ public override async Task
public sealed class ODataResourceWrapper : ODataItemBase
- {
+ {
///
/// Initializes a new instance of .
///
/// The wrapped item.
- public ODataResourceWrapper(ODataResource item)
+ public ODataResourceWrapper(ODataResourceBase item)
: base(item)
{
NestedResourceInfos = new List();
+ ResourceBase = item;
}
+
+ ///
+ /// Gets the wrapped .
+ ///
+ public ODataResourceBase ResourceBase {get;}
///
- /// Gets the wrapped .
+ /// Gets the wrapped . This will return null for deleted resources.
///
+ [Obsolete("Please use ResourceBase instead")]
public ODataResource Resource
{
get
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ResourceSetType.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ResourceSetType.cs
new file mode 100644
index 0000000000..70799cd070
--- /dev/null
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ResourceSetType.cs
@@ -0,0 +1,25 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Microsoft.AspNet.OData.Formatter.Deserialization
+{
+ ///
+ /// Enum to determine the type of Resource Set
+ ///
+ internal enum ResourceSetType
+ {
+ ///
+ /// A normal ResourceSet
+ ///
+ ResourceSet,
+
+ ///
+ /// A Delta Resource Set
+ ///
+ DeltaResourceSet
+ }
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/ETag.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/ETag.cs
index fb77643637..885eea8f3f 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/ETag.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/ETag.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/ETagOfTEntity.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/ETagOfTEntity.cs
index 7385e9ce60..3ec0e0036f 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/ETagOfTEntity.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/ETagOfTEntity.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Linq;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/EdmLibHelpers.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/EdmLibHelpers.cs
index 7a907d1887..659c5bc2e6 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/EdmLibHelpers.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/EdmLibHelpers.cs
@@ -1,7 +1,12 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
+using System.Collections;
using System.Collections.Generic;
#if NETFX // System.Data.Linq.Binary is only supported in the AspNet version.
using System.Data.Linq;
@@ -130,13 +135,23 @@ private static IEdmType GetEdmType(IEdmModel edmModel, Type clrType, bool testCo
{
if (testCollections)
{
+ Type entityType;
+
+ if (IsDeltaSetWrapper(clrType, out entityType))
+ {
+ IEdmType elementType = GetEdmType(edmModel, entityType, testCollections: false);
+ if (elementType != null)
+ {
+ return new EdmCollectionType(elementType.ToEdmTypeReference(IsNullable(entityType)));
+ }
+ }
+
Type enumerableOfT = ExtractGenericInterface(clrType, typeof(IEnumerable<>));
if (enumerableOfT != null)
{
Type elementClrType = enumerableOfT.GetGenericArguments()[0];
- // IEnumerable> is a collection of T.
- Type entityType;
+ // IEnumerable> is a collection of T.
if (IsSelectExpandWrapper(elementClrType, out entityType))
{
elementClrType = entityType;
@@ -901,14 +916,17 @@ internal static IEdmTypeReference GetExpectedPayloadType(Type type, ODataPath pa
{
IEdmTypeReference expectedPayloadType = null;
- if (typeof(IEdmObject).IsAssignableFrom(type))
+ if (typeof(IEdmObject).IsAssignableFrom(type) || typeof(IDeltaSet).IsAssignableFrom(type))
{
// typeless mode. figure out the expected payload type from the OData Path.
IEdmType edmType = path.EdmType;
if (edmType != null)
{
expectedPayloadType = EdmLibHelpers.ToEdmTypeReference(edmType, isNullable: false);
- if (expectedPayloadType.TypeKind() == EdmTypeKind.Collection)
+
+ //This loop should execute only if its not a type of edmchangedobjectcollection, In case of edmchangedobjectcollection,
+ //Expectedpayloadtype should not be of elementytype, but of collection.
+ if (expectedPayloadType.TypeKind() == EdmTypeKind.Collection && !(typeof(ICollection).IsAssignableFrom(type) || typeof(IDeltaSet).IsAssignableFrom(type)))
{
IEdmTypeReference elementType = expectedPayloadType.AsCollection().ElementType();
if (elementType.IsEntity())
@@ -1041,6 +1059,7 @@ private static IEdmPrimitiveType GetPrimitiveType(EdmPrimitiveTypeKind primitive
}
private static bool IsSelectExpandWrapper(Type type, out Type entityType) => IsTypeWrapper(typeof(SelectExpandWrapper<>), type, out entityType);
+ private static bool IsDeltaSetWrapper(Type type, out Type entityType) => IsTypeWrapper(typeof(DeltaSet<>), type, out entityType);
internal static bool IsComputeWrapper(Type type, out Type entityType) => IsTypeWrapper(typeof(ComputeWrapper<>), type, out entityType);
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/EdmObjectHelper.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/EdmObjectHelper.cs
index bbf0fd96c9..0e4509c6e3 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/EdmObjectHelper.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/EdmObjectHelper.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections;
using System.Diagnostics.Contracts;
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/EdmPrimitiveHelpers.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/EdmPrimitiveHelpers.cs
index b93c16ddfc..f99982ce33 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/EdmPrimitiveHelpers.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/EdmPrimitiveHelpers.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.ComponentModel.DataAnnotations;
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/EdmTypeReferenceEqualityComparer.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/EdmTypeReferenceEqualityComparer.cs
index f502275efa..8b7bf9d35e 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/EdmTypeReferenceEqualityComparer.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/EdmTypeReferenceEqualityComparer.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Diagnostics.Contracts;
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/IETagHandler.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/IETagHandler.cs
index 4e98d05874..564650a0f4 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/IETagHandler.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/IETagHandler.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/ODataBinaryValueMediaTypeMapping.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/ODataBinaryValueMediaTypeMapping.cs
index ab02aec3ae..cbab5ba8c8 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/ODataBinaryValueMediaTypeMapping.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/ODataBinaryValueMediaTypeMapping.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.OData.Edm;
using Microsoft.OData.UriParser;
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/ODataCountMediaTypeMapping.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/ODataCountMediaTypeMapping.cs
index 5ff4597ad7..d7114fd40f 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/ODataCountMediaTypeMapping.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/ODataCountMediaTypeMapping.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Linq;
using Microsoft.OData.UriParser;
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/ODataEnumValueMediaTypeMapping.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/ODataEnumValueMediaTypeMapping.cs
index 3527518300..1fe73617be 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/ODataEnumValueMediaTypeMapping.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/ODataEnumValueMediaTypeMapping.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.OData.Edm;
using Microsoft.OData.UriParser;
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/ODataInputFormatterHelper.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/ODataInputFormatterHelper.cs
index 3ccc9a0341..8ecd8ed6ce 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/ODataInputFormatterHelper.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/ODataInputFormatterHelper.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/ODataMediaTypes.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/ODataMediaTypes.cs
index 3dbc4523d6..8496e956a0 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/ODataMediaTypes.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/ODataMediaTypes.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/ODataMessageWrapper.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/ODataMessageWrapper.cs
index 16dc5406bd..d8e41b08d9 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/ODataMessageWrapper.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/ODataMessageWrapper.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
@@ -168,4 +172,4 @@ protected void Dispose(bool disposing)
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/ODataMetadataLevel.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/ODataMetadataLevel.cs
index 1cde7a780b..a33df4ae34 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/ODataMetadataLevel.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/ODataMetadataLevel.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
namespace Microsoft.AspNet.OData.Formatter
{
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/ODataModelBinderConverter.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/ODataModelBinderConverter.cs
index 7ac3f06f75..f7eea7088c 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/ODataModelBinderConverter.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/ODataModelBinderConverter.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections;
@@ -31,7 +35,9 @@ namespace Microsoft.AspNet.OData.Formatter
public static class ODataModelBinderConverter
{
private static readonly MethodInfo EnumTryParseMethod = typeof(Enum).GetMethods()
- .Single(m => m.Name == "TryParse" && m.GetParameters().Length == 2);
+ .Single(m => m.Name.Equals("TryParse", StringComparison.Ordinal)
+ && m.GetParameters().Length == 2
+ && m.GetParameters()[0].ParameterType.Equals(typeof(string)));
private static readonly MethodInfo CastMethodInfo = typeof(Enumerable).GetMethod("Cast");
@@ -331,7 +337,7 @@ private static object ConvertResource(ODataMessageReader oDataMessageReader, IEd
if (edmTypeReference.IsEntity())
{
IEdmEntityTypeReference entityType = edmTypeReference.AsEntity();
- return CovertResourceId(value, topLevelResource.Resource, entityType, readContext);
+ return CovertResourceId(value, topLevelResource.ResourceBase, entityType, readContext);
}
return value;
@@ -344,14 +350,14 @@ private static IEnumerable CovertResourceSetIds(IEnumerable sources, ODataResour
int i = 0;
foreach (object item in sources)
{
- object newItem = CovertResourceId(item, resourceSet.Resources[i].Resource, entityTypeReference,
+ object newItem = CovertResourceId(item, resourceSet.Resources[i].ResourceBase, entityTypeReference,
readContext);
i++;
yield return newItem;
}
}
- private static object CovertResourceId(object source, ODataResource resource,
+ private static object CovertResourceId(object source, ODataResourceBase resource,
IEdmEntityTypeReference entityTypeReference, ODataDeserializerContext readContext)
{
Contract.Assert(resource != null);
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/ODataOutputFormatterHelper.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/ODataOutputFormatterHelper.cs
index 8b12a249c2..198b5d61e7 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/ODataOutputFormatterHelper.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/ODataOutputFormatterHelper.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
@@ -91,7 +95,7 @@ internal static bool CanWriteType(
ODataPayloadKind? payloadKind;
Type elementType;
- if (typeof(IEdmObject).IsAssignableFrom(type) ||
+ if (typeof(IDeltaSet).IsAssignableFrom(type) || typeof(IEdmObject).IsAssignableFrom(type) ||
(TypeHelper.IsCollection(type, out elementType) && typeof(IEdmObject).IsAssignableFrom(elementType)))
{
payloadKind = GetEdmObjectPayloadKind(type, internalRequest);
@@ -203,6 +207,7 @@ internal static void WriteToStream(
writeContext.Path = path;
writeContext.MetadataLevel = metadataLevel;
writeContext.QueryOptions = internalRequest.Context.QueryOptions;
+ writeContext.Type = type;
//Set the SelectExpandClause on the context if it was explicitly specified.
if (selectExpandDifferentFromQueryOptions != null)
@@ -247,7 +252,7 @@ internal static void WriteToStream(
{
return ODataPayloadKind.ResourceSet;
}
- else if (typeof(IEdmChangedObject).IsAssignableFrom(elementType))
+ else if (typeof(IDeltaSetItem).IsAssignableFrom(elementType) || typeof(IEdmChangedObject).IsAssignableFrom(elementType))
{
return ODataPayloadKind.Delta;
}
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/ODataPrimitiveValueMediaTypeMapping.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/ODataPrimitiveValueMediaTypeMapping.cs
index 4b0696c346..d4567da66f 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/ODataPrimitiveValueMediaTypeMapping.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/ODataPrimitiveValueMediaTypeMapping.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.OData.Edm;
using Microsoft.OData.UriParser;
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/ODataRawValueMediaTypeMapping.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/ODataRawValueMediaTypeMapping.cs
index 12d22cd695..7898c9df6d 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/ODataRawValueMediaTypeMapping.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/ODataRawValueMediaTypeMapping.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Linq;
using System.Net.Http;
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/ODataStreamMediaTypeMapping.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/ODataStreamMediaTypeMapping.cs
index aea4019a34..e7d605885b 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/ODataStreamMediaTypeMapping.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/ODataStreamMediaTypeMapping.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
namespace Microsoft.AspNet.OData.Formatter
{
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/ODataValueExtensions.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/ODataValueExtensions.cs
index 784fc9d77d..c24f3609b5 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/ODataValueExtensions.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/ODataValueExtensions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.OData;
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/QueryStringMediaTypeMapping.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/QueryStringMediaTypeMapping.cs
index 3de58c1fdf..1f77618159 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/QueryStringMediaTypeMapping.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/QueryStringMediaTypeMapping.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Linq;
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/DefaultODataSerializerProvider.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/DefaultODataSerializerProvider.cs
index 3a863c676b..f814563e25 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/DefaultODataSerializerProvider.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/DefaultODataSerializerProvider.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
@@ -108,6 +112,10 @@ internal ODataSerializer GetODataPayloadSerializerImpl(Type type, Func();
}
+ else if(TypeHelper.IsTypeAssignableFrom(typeof(IDeltaSet), type))
+ {
+ return _rootContainer.GetRequiredService();
+ }
// Get the model. Using a Func to delay evaluation of the model
// until after the above checks have passed.
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/EntitySelfLinks.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/EntitySelfLinks.cs
index a0c1fea720..e50da41329 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/EntitySelfLinks.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/EntitySelfLinks.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataCollectionSerializer.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataCollectionSerializer.cs
index f38479fd12..c70ba79ff8 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataCollectionSerializer.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataCollectionSerializer.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections;
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataDeltaFeedSerializer.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataDeltaFeedSerializer.cs
index 617b4bbff1..e0e0aafb9e 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataDeltaFeedSerializer.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataDeltaFeedSerializer.cs
@@ -1,9 +1,16 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
+using System.CodeDom;
using System.Collections;
+using System.Collections.Generic;
using System.Diagnostics.Contracts;
+using System.Reflection;
using System.Runtime.Serialization;
using System.Threading.Tasks;
using Microsoft.AspNet.OData.Builder;
@@ -21,6 +28,7 @@ namespace Microsoft.AspNet.OData.Formatter.Serialization
public class ODataDeltaFeedSerializer : ODataEdmTypeSerializer
{
private const string DeltaFeed = "deltafeed";
+ IEdmStructuredTypeReference _elementType;
///
/// Initializes a new instance of .
@@ -56,6 +64,7 @@ public override void WriteObject(object graph, Type type, ODataMessageWriter mes
}
IEdmTypeReference feedType = writeContext.GetEdmType(graph, type);
+
Contract.Assert(feedType != null);
IEdmEntityTypeReference entityType = GetResourceType(feedType).AsEntity();
@@ -89,6 +98,7 @@ public override async Task WriteObjectAsync(object graph, Type type, ODataMessag
}
IEdmTypeReference feedType = writeContext.GetEdmType(graph, type);
+
Contract.Assert(feedType != null);
IEdmEntityTypeReference entityType = GetResourceType(feedType).AsEntity();
@@ -182,6 +192,7 @@ private void WriteFeed(IEnumerable enumerable, IEdmTypeReference feedType, OData
Contract.Assert(feedType != null);
IEdmStructuredTypeReference elementType = GetResourceType(feedType);
+ _elementType = elementType;
if (elementType.IsComplex())
{
@@ -230,13 +241,31 @@ private void WriteFeed(IEnumerable enumerable, IEdmTypeReference feedType, OData
}
lastResource = entry;
- IEdmChangedObject edmChangedObject = entry as IEdmChangedObject;
- if (edmChangedObject == null)
+
+ EdmDeltaEntityKind deltaEntityKind;
+ if (writeContext.IsUntyped)
{
- throw new SerializationException(Error.Format(SRResources.CannotWriteType, GetType().Name, enumerable.GetType().FullName));
+ IEdmChangedObject edmChangedObject = entry as IEdmChangedObject;
+ if (edmChangedObject == null)
+ {
+ throw new SerializationException(Error.Format(SRResources.CannotWriteType, GetType().Name, enumerable.GetType().FullName));
+ }
+
+ deltaEntityKind = edmChangedObject.DeltaKind;
}
+ else
+ {
+ IDeltaSetItem deltaSetItem = entry as IDeltaSetItem;
- switch (edmChangedObject.DeltaKind)
+ if (deltaSetItem == null)
+ {
+ throw new SerializationException(Error.Format(SRResources.CannotWriteType, GetType().Name, enumerable.GetType().FullName));
+ }
+
+ deltaEntityKind = deltaSetItem.DeltaKind;
+ }
+
+ switch (deltaEntityKind)
{
case EdmDeltaEntityKind.DeletedEntry:
WriteDeltaDeletedEntry(entry, writer, writeContext);
@@ -250,6 +279,7 @@ private void WriteFeed(IEnumerable enumerable, IEdmTypeReference feedType, OData
case EdmDeltaEntityKind.Entry:
{
ODataResourceSerializer entrySerializer = SerializerProvider.GetEdmTypeSerializer(elementType) as ODataResourceSerializer;
+
if (entrySerializer == null)
{
throw new SerializationException(
@@ -285,6 +315,7 @@ private async Task WriteFeedAsync(IEnumerable enumerable, IEdmTypeReference feed
Contract.Assert(feedType != null);
IEdmStructuredTypeReference elementType = GetResourceType(feedType);
+ _elementType = elementType;
if (elementType.IsComplex())
{
@@ -333,13 +364,32 @@ private async Task WriteFeedAsync(IEnumerable enumerable, IEdmTypeReference feed
}
lastResource = entry;
- IEdmChangedObject edmChangedObject = entry as IEdmChangedObject;
- if (edmChangedObject == null)
+
+ EdmDeltaEntityKind deltaEntityKind;
+ if (writeContext.IsUntyped)
+ {
+ IEdmChangedObject edmChangedObject = entry as IEdmChangedObject;
+ if (edmChangedObject == null)
+ {
+ throw new SerializationException(Error.Format(SRResources.CannotWriteType, GetType().Name, enumerable.GetType().FullName));
+ }
+
+ deltaEntityKind = edmChangedObject.DeltaKind;
+ }
+ else
{
- throw new SerializationException(Error.Format(SRResources.CannotWriteType, GetType().Name, enumerable.GetType().FullName));
+ IDeltaSetItem deltaSetItem = entry as IDeltaSetItem;
+
+ if (deltaSetItem == null)
+ {
+ throw new SerializationException(Error.Format(SRResources.CannotWriteType, GetType().Name, enumerable.GetType().FullName));
+ }
+
+ deltaEntityKind = deltaSetItem.DeltaKind;
}
+
- switch (edmChangedObject.DeltaKind)
+ switch (deltaEntityKind)
{
case EdmDeltaEntityKind.DeletedEntry:
await WriteDeltaDeletedEntryAsync(entry, writer, writeContext);
@@ -434,15 +484,23 @@ public virtual ODataDeltaResourceSet CreateODataDeltaFeed(IEnumerable feedInstan
///
/// The object to be written.
/// The to be used for writing.
- /// The .
+ /// The .
public virtual void WriteDeltaDeletedEntry(object graph, ODataWriter writer, ODataSerializerContext writeContext)
{
- ODataDeletedResource deletedResource = GetDeletedResource(graph);
-
- if (deletedResource != null)
+ ODataResourceSerializer serializer = SerializerProvider.GetEdmTypeSerializer(_elementType) as ODataResourceSerializer;
+ ResourceContext resourceContext = serializer.GetResourceContext(graph, writeContext);
+ SelectExpandNode selectExpandNode = serializer.CreateSelectExpandNode(resourceContext);
+
+ if (selectExpandNode != null)
{
- writer.WriteStart(deletedResource);
- writer.WriteEnd();
+ ODataDeletedResource deletedResource = GetDeletedResource(graph, resourceContext, serializer, selectExpandNode, writeContext.IsUntyped);
+
+ if (deletedResource != null)
+ {
+ writer.WriteStart(deletedResource);
+ serializer.WriteDeltaComplexProperties(selectExpandNode, resourceContext, writer);
+ writer.WriteEnd();
+ }
}
}
@@ -452,14 +510,22 @@ public virtual void WriteDeltaDeletedEntry(object graph, ODataWriter writer, ODa
///
/// The object to be written.
/// The to be used for writing.
- /// The .
+ /// The .
public virtual async Task WriteDeltaDeletedEntryAsync(object graph, ODataWriter writer, ODataSerializerContext writeContext)
{
- ODataDeletedResource deletedResource = GetDeletedResource(graph);
- if (deletedResource != null)
+ ODataResourceSerializer serializer = SerializerProvider.GetEdmTypeSerializer(_elementType) as ODataResourceSerializer;
+ ResourceContext resourceContext = serializer.GetResourceContext(graph, writeContext);
+ SelectExpandNode selectExpandNode = serializer.CreateSelectExpandNode(resourceContext);
+
+ if (selectExpandNode != null)
{
- await writer.WriteStartAsync(deletedResource);
- await writer.WriteEndAsync();
+ ODataDeletedResource deletedResource = GetDeletedResource(graph, resourceContext, serializer, selectExpandNode, writeContext.IsUntyped);
+
+ if (deletedResource != null)
+ {
+ await writer.WriteStartAsync(deletedResource);
+ await writer.WriteEndAsync();
+ }
}
}
@@ -469,7 +535,7 @@ public virtual async Task WriteDeltaDeletedEntryAsync(object graph, ODataWriter
///
/// The object to be written.
/// The to be used for writing.
- /// The .
+ /// The .
public virtual void WriteDeltaDeletedLink(object graph, ODataWriter writer, ODataSerializerContext writeContext)
{
ODataDeltaDeletedLink deltaDeletedLink = GetDeletedLink(graph);
@@ -485,7 +551,7 @@ public virtual void WriteDeltaDeletedLink(object graph, ODataWriter writer, ODat
///
/// The object to be written.
/// The to be used for writing.
- /// The .
+ /// The .
public virtual async Task WriteDeltaDeletedLinkAsync(object graph, ODataWriter writer, ODataSerializerContext writeContext)
{
ODataDeltaDeletedLink deltaDeletedLink = GetDeletedLink(graph);
@@ -501,7 +567,7 @@ public virtual async Task WriteDeltaDeletedLinkAsync(object graph, ODataWriter w
///
/// The object to be written.
/// The to be used for writing.
- /// The .
+ /// The .
public virtual void WriteDeltaLink(object graph, ODataWriter writer, ODataSerializerContext writeContext)
{
ODataDeltaLink deltaLink = GetDeltaLink(graph);
@@ -517,7 +583,7 @@ public virtual void WriteDeltaLink(object graph, ODataWriter writer, ODataSerial
///
/// The object to be written.
/// The to be used for writing.
- /// The .
+ /// The .
public async Task WriteDeltaLinkAsync(object graph, ODataWriter writer, ODataSerializerContext writeContext)
{
ODataDeltaLink deltaLink = GetDeltaLink(graph);
@@ -527,26 +593,46 @@ public async Task WriteDeltaLinkAsync(object graph, ODataWriter writer, ODataSer
}
}
- private ODataDeletedResource GetDeletedResource(object graph)
+
+ private ODataDeletedResource GetDeletedResource(object graph, ResourceContext resourceContext, ODataResourceSerializer serializer, SelectExpandNode selectExpandNode, bool isUntyped)
{
- EdmDeltaDeletedEntityObject edmDeltaDeletedEntity = graph as EdmDeltaDeletedEntityObject;
- if (edmDeltaDeletedEntity == null)
+ IEdmNavigationSource navigationSource;
+ ODataDeletedResource deletedResource = serializer.CreateDeletedResource(selectExpandNode, resourceContext);
+
+ if (isUntyped)
{
- throw new SerializationException(Error.Format(SRResources.CannotWriteType, GetType().Name, graph.GetType().FullName));
- }
+ EdmDeltaDeletedEntityObject edmDeltaDeletedEntity = graph as EdmDeltaDeletedEntityObject;
+ if (edmDeltaDeletedEntity == null)
+ {
+ throw new SerializationException(Error.Format(SRResources.CannotWriteType, GetType().Name, graph.GetType().FullName));
+ }
- Uri id = StringToUri(edmDeltaDeletedEntity.Id);
- ODataDeletedResource deletedResource = new ODataDeletedResource(id, edmDeltaDeletedEntity.Reason);
+ deletedResource.Id = StringToUri(edmDeltaDeletedEntity.Id??string.Empty);
+ deletedResource.Reason = edmDeltaDeletedEntity.Reason;
+ navigationSource = edmDeltaDeletedEntity.NavigationSource;
+ }
+ else
+ {
+ IDeltaDeletedEntityObject deltaDeletedEntity = graph as IDeltaDeletedEntityObject;
+ if (deltaDeletedEntity == null)
+ {
+ throw new SerializationException(Error.Format(SRResources.CannotWriteType, GetType().Name, graph.GetType().FullName));
+ }
- if (edmDeltaDeletedEntity.NavigationSource != null)
+ deletedResource.Id = deltaDeletedEntity.Id;
+ deletedResource.Reason = deltaDeletedEntity.Reason;
+ navigationSource = deltaDeletedEntity.NavigationSource;
+ }
+
+ if (navigationSource != null)
{
ODataResourceSerializationInfo serializationInfo = new ODataResourceSerializationInfo
{
- NavigationSourceName = edmDeltaDeletedEntity.NavigationSource.Name
+ NavigationSourceName = navigationSource.Name
};
deletedResource.SetSerializationInfo(serializationInfo);
}
-
+
return deletedResource;
}
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataEdmTypeSerializer.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataEdmTypeSerializer.cs
index e3e5ffba1a..f1065cf86a 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataEdmTypeSerializer.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataEdmTypeSerializer.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Diagnostics.Contracts;
using System.Threading.Tasks;
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataEntityReferenceLinkSerializer.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataEntityReferenceLinkSerializer.cs
index ab8593a850..8e95550ea6 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataEntityReferenceLinkSerializer.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataEntityReferenceLinkSerializer.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Runtime.CompilerServices;
@@ -83,4 +87,4 @@ private ODataEntityReferenceLink GetEntityReferenceLink(object graph)
return entityReferenceLink;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataEntityReferenceLinksSerializer.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataEntityReferenceLinksSerializer.cs
index 8ea1ee3bc4..db5037db24 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataEntityReferenceLinksSerializer.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataEntityReferenceLinksSerializer.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataEnumSerializer.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataEnumSerializer.cs
index d414b388c5..4d31927fce 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataEnumSerializer.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataEnumSerializer.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Diagnostics.Contracts;
@@ -189,4 +193,4 @@ private static bool ShouldSuppressTypeNameSerialization(ODataMetadataLevel metad
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataErrorSerializer.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataErrorSerializer.cs
index 33d3dffe18..95b9e7bc3b 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataErrorSerializer.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataErrorSerializer.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Runtime.Serialization;
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataMetadataSerializer.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataMetadataSerializer.cs
index 862b0e6a27..fb9f335031 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataMetadataSerializer.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataMetadataSerializer.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Threading.Tasks;
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataPayloadKindHelper.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataPayloadKindHelper.cs
index 840b3472ec..578233c3fb 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataPayloadKindHelper.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataPayloadKindHelper.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Common;
using Microsoft.OData;
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataPrimitiveSerializer.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataPrimitiveSerializer.cs
index de7f9f78b3..9c20c83c00 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataPrimitiveSerializer.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataPrimitiveSerializer.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
#if NETFX // System.Data.Linq.Binary is only supported in the AspNet version.
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataRawValueSerializer.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataRawValueSerializer.cs
index 9f5bc902ae..24171dd48e 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataRawValueSerializer.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataRawValueSerializer.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Threading.Tasks;
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataResourceSerializer.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataResourceSerializer.cs
index 02ffd1b8c8..9783fd9052 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataResourceSerializer.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataResourceSerializer.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Concurrent;
@@ -234,7 +238,7 @@ private async Task WriteDeltaResourceAsync(object graph, ODataWriter writer, ODa
}
}
- private ResourceContext GetResourceContext(object graph, ODataSerializerContext writeContext)
+ internal ResourceContext GetResourceContext(object graph, ODataSerializerContext writeContext)
{
Contract.Assert(writeContext != null);
@@ -249,7 +253,7 @@ private ResourceContext GetResourceContext(object graph, ODataSerializerContext
return resourceContext;
}
- private void WriteDeltaComplexProperties(SelectExpandNode selectExpandNode,
+ internal void WriteDeltaComplexProperties(SelectExpandNode selectExpandNode,
ResourceContext resourceContext, ODataWriter writer)
{
Contract.Assert(resourceContext != null);
@@ -684,6 +688,14 @@ public virtual SelectExpandNode CreateSelectExpandNode(ResourceContext resourceC
/// The created .
public virtual ODataResource CreateResource(SelectExpandNode selectExpandNode, ResourceContext resourceContext)
{
+ ODataResource resource = CreateResourceBase(selectExpandNode, resourceContext, false) as ODataResource;
+ return resource;
+ }
+
+
+ private ODataResourceBase CreateResourceBase(SelectExpandNode selectExpandNode, ResourceContext resourceContext, bool isDeletedResource)
+ {
+
if (selectExpandNode == null)
{
throw Error.ArgumentNull("selectExpandNode");
@@ -696,6 +708,14 @@ public virtual ODataResource CreateResource(SelectExpandNode selectExpandNode, R
if (resourceContext.SerializerContext.ExpandReference)
{
+ if (isDeletedResource)
+ {
+ return new ODataDeletedResource
+ {
+ Id = resourceContext.GenerateSelfLink(false)
+ };
+ }
+
return new ODataResource
{
Id = resourceContext.GenerateSelfLink(false)
@@ -703,11 +723,25 @@ public virtual ODataResource CreateResource(SelectExpandNode selectExpandNode, R
}
string typeName = resourceContext.StructuredType.FullTypeName();
- ODataResource resource = new ODataResource
+ ODataResourceBase resource;
+
+ if (isDeletedResource)
{
- TypeName = typeName,
- Properties = CreateStructuralPropertyBag(selectExpandNode, resourceContext),
- };
+ resource = new ODataDeletedResource
+ {
+ TypeName = typeName,
+ Properties = CreateStructuralPropertyBag(selectExpandNode, resourceContext),
+ };
+ }
+ else
+ {
+ resource = new ODataResource
+ {
+ TypeName = typeName,
+ Properties = CreateStructuralPropertyBag(selectExpandNode, resourceContext),
+ };
+ }
+
if (resourceContext.EdmObject is EdmDeltaEntityObject && resourceContext.NavigationSource != null)
{
@@ -756,7 +790,7 @@ public virtual ODataResource CreateResource(SelectExpandNode selectExpandNode, R
AddTypeNameAnnotationAsNeeded(resource, pathType, resourceContext.SerializerContext.MetadataLevel);
}
- if (resourceContext.StructuredType.TypeKind == EdmTypeKind.Entity && resourceContext.NavigationSource != null)
+ if (!isDeletedResource && resourceContext.StructuredType.TypeKind == EdmTypeKind.Entity && resourceContext.NavigationSource != null)
{
if (!(resourceContext.NavigationSource is IEdmContainedEntitySet))
{
@@ -790,6 +824,19 @@ public virtual ODataResource CreateResource(SelectExpandNode selectExpandNode, R
return resource;
}
+ ///
+ /// Creates the to be written while writing this resource.
+ ///
+ /// The describing the response graph.
+ /// The context for the resource instance being written.
+ /// The created .
+ public virtual ODataDeletedResource CreateDeletedResource(SelectExpandNode selectExpandNode, ResourceContext resourceContext)
+ {
+ ODataDeletedResource resource = CreateResourceBase(selectExpandNode, resourceContext, true) as ODataDeletedResource;
+ return resource;
+ }
+
+
///
/// Appends the dynamic properties of primitive, enum or the collection of them into the given .
/// If the dynamic property is a property of the complex or collection of complex, it will be saved into
@@ -800,7 +847,7 @@ public virtual ODataResource CreateResource(SelectExpandNode selectExpandNode, R
/// The context for the resource instance being written.
[SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling", Justification = "Relies on many classes.")]
[SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity", Justification = "These are simple conversion function and cannot be split up.")]
- public virtual void AppendDynamicProperties(ODataResource resource, SelectExpandNode selectExpandNode,
+ public virtual void AppendDynamicProperties(ODataResourceBase resource, SelectExpandNode selectExpandNode,
ResourceContext resourceContext)
{
Contract.Assert(resource != null);
@@ -927,102 +974,60 @@ public virtual void AppendDynamicProperties(ODataResource resource, SelectExpand
///
/// The describing the resource, which is being annotated.
/// The context for the resource instance, which is being annotated.
- public virtual void AppendInstanceAnnotations(ODataResource resource, ResourceContext resourceContext)
+ public virtual void AppendInstanceAnnotations(ODataResourceBase resource, ResourceContext resourceContext)
{
IEdmStructuredType structuredType = resourceContext.StructuredType;
IEdmStructuredObject structuredObject = resourceContext.EdmObject;
+
+ //For appending transient and persistent instance annotations for both enity object and normal resources
+
PropertyInfo instanceAnnotationInfo = EdmLibHelpers.GetInstanceAnnotationsContainer(structuredType,
resourceContext.EdmModel);
- object value;
-
- if (instanceAnnotationInfo == null || structuredObject == null ||
- !structuredObject.TryGetPropertyValue(instanceAnnotationInfo.Name, out value) || value == null)
- {
- return;
- }
+ EdmEntityObject edmEntityObject = null;
+ object instanceAnnotations = null;
+ IODataInstanceAnnotationContainer transientAnnotations = null;
- IODataInstanceAnnotationContainer instanceAnnotationContainer = value as IODataInstanceAnnotationContainer;
+ IDelta delta = null;
- if (instanceAnnotationContainer != null)
+ if (resourceContext.SerializerContext.IsDeltaOfT)
{
- IDictionary clrAnnotations = instanceAnnotationContainer.GetResourceAnnotations();
-
- if (clrAnnotations != null)
- {
- foreach (KeyValuePair annotation in clrAnnotations)
- {
- AddODataAnnotations(resource.InstanceAnnotations, resourceContext, annotation);
- }
- }
-
- foreach(ODataProperty property in resource.Properties)
- {
- string propertyName = property.Name;
-
- if (property.InstanceAnnotations == null)
- {
- property.InstanceAnnotations = new List();
- }
-
- IDictionary propertyAnnotations = instanceAnnotationContainer.GetPropertyAnnotations(propertyName);
-
- if (propertyAnnotations != null)
- {
- foreach (KeyValuePair annotation in propertyAnnotations)
- {
- AddODataAnnotations(property.InstanceAnnotations, resourceContext, annotation);
- }
- }
- }
+ delta = resourceContext.ResourceInstance as IDelta;
}
- }
- private void AddODataAnnotations(ICollection InstanceAnnotations, ResourceContext resourceContext, KeyValuePair annotation)
- {
- ODataValue annotationValue = null;
-
- if (annotation.Value != null)
+ if (delta != null)
{
- IEdmTypeReference edmTypeReference = resourceContext.SerializerContext.GetEdmType(annotation.Value,
- annotation.Value.GetType());
+ if (instanceAnnotationInfo != null)
+ {
+ delta.TryGetPropertyValue(instanceAnnotationInfo.Name, out instanceAnnotations);
+
+ }
- ODataEdmTypeSerializer edmTypeSerializer = GetEdmTypeSerializer(edmTypeReference);
+ IDeltaSetItem deltaitem = resourceContext.ResourceInstance as IDeltaSetItem;
- if (edmTypeSerializer != null)
+ if(deltaitem != null)
{
- annotationValue = edmTypeSerializer.CreateODataValue(annotation.Value, edmTypeReference, resourceContext.SerializerContext);
+ transientAnnotations = deltaitem.TransientInstanceAnnotationContainer;
}
}
else
{
- annotationValue = new ODataNullValue();
- }
-
- if (annotationValue != null)
- {
- InstanceAnnotations.Add(new ODataInstanceAnnotation(annotation.Key, annotationValue));
- }
- }
+ if (instanceAnnotationInfo == null || structuredObject == null ||
+ !structuredObject.TryGetPropertyValue(instanceAnnotationInfo.Name, out instanceAnnotations) || instanceAnnotations == null)
+ {
+ edmEntityObject = structuredObject as EdmEntityObject;
- private ODataEdmTypeSerializer GetEdmTypeSerializer(IEdmTypeReference edmTypeReference)
- {
- ODataEdmTypeSerializer edmTypeSerializer;
-
- if (edmTypeReference.IsCollection())
- {
- edmTypeSerializer = new ODataCollectionSerializer(SerializerProvider, true);
- }
- else if (edmTypeReference.IsStructured())
- {
- edmTypeSerializer = new ODataResourceValueSerializer(SerializerProvider);
- }
- else
- {
- edmTypeSerializer = SerializerProvider.GetEdmTypeSerializer(edmTypeReference);
+ if (edmEntityObject != null)
+ {
+ instanceAnnotations = edmEntityObject.PersistentInstanceAnnotationsContainer;
+ transientAnnotations = edmEntityObject.TransientInstanceAnnotationContainer;
+ }
+ }
}
- return edmTypeSerializer;
+ ODataSerializerHelper.AppendInstanceAnnotations(resource, resourceContext, instanceAnnotations, SerializerProvider);
+
+ ODataSerializerHelper.AppendInstanceAnnotations(resource, resourceContext, transientAnnotations, SerializerProvider);
}
///
@@ -1613,6 +1618,8 @@ private IEnumerable CreateStructuralPropertyBag(SelectExpandNode
structuralProperties = structuralProperties.Where(p => changedProperties.Contains(p.Name));
}
+ bool isDeletedEntity = resourceContext.EdmObject is EdmDeltaDeletedEntityObject;
+
foreach (IEdmStructuralProperty structuralProperty in structuralProperties)
{
if (structuralProperty.Type != null && structuralProperty.Type.IsStream())
@@ -1622,11 +1629,13 @@ private IEnumerable CreateStructuralPropertyBag(SelectExpandNode
}
ODataProperty property = CreateStructuralProperty(structuralProperty, resourceContext);
- if (property != null)
+ if (property == null || (isDeletedEntity && property.Value == null) )
{
- properties.Add(property);
+ continue;
}
- }
+
+ properties.Add(property);
+ }
}
return properties;
@@ -1944,7 +1953,7 @@ private static IEdmStructuredType GetODataPathType(ODataSerializerContext serial
}
}
- internal static void AddTypeNameAnnotationAsNeeded(ODataResource resource, IEdmStructuredType odataPathType,
+ internal static void AddTypeNameAnnotationAsNeeded(ODataResourceBase resource, IEdmStructuredType odataPathType,
ODataMetadataLevel metadataLevel)
{
// ODataLib normally has the caller decide whether or not to serialize properties by leaving properties
@@ -1969,7 +1978,7 @@ internal static void AddTypeNameAnnotationAsNeeded(ODataResource resource, IEdmS
resource.TypeAnnotation = new ODataTypeAnnotation(typeName);
}
- internal static void AddTypeNameAnnotationAsNeededForComplex(ODataResource resource, ODataMetadataLevel metadataLevel)
+ internal static void AddTypeNameAnnotationAsNeededForComplex(ODataResourceBase resource, ODataMetadataLevel metadataLevel)
{
// ODataLib normally has the caller decide whether or not to serialize properties by leaving properties
// null when values should not be serialized. The TypeName property is different and should always be
@@ -2043,7 +2052,7 @@ internal static bool ShouldOmitOperation(IEdmOperation operation, OperationLinkB
}
}
- internal static bool ShouldSuppressTypeNameSerialization(ODataResource resource, IEdmStructuredType edmType,
+ internal static bool ShouldSuppressTypeNameSerialization(ODataResourceBase resource, IEdmStructuredType edmType,
ODataMetadataLevel metadataLevel)
{
Contract.Assert(resource != null);
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataResourceSetSerializer.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataResourceSetSerializer.cs
index 98ba88f5eb..e8a9ef1084 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataResourceSetSerializer.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataResourceSetSerializer.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections;
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataResourceValueSerializer.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataResourceValueSerializer.cs
index 0be29f7df0..8f1f1515a2 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataResourceValueSerializer.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataResourceValueSerializer.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataSerializer.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataSerializer.cs
index ddbff2c5b5..d1773cc4ce 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataSerializer.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataSerializer.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Threading.Tasks;
@@ -59,4 +63,4 @@ public virtual Task WriteObjectAsync(object graph, Type type, ODataMessageWriter
return Task.Run(() => WriteObject(graph, type, messageWriter, writeContext));
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataSerializerContext.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataSerializerContext.cs
index f98cfce09c..914ff6054a 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataSerializerContext.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataSerializerContext.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
@@ -23,6 +27,8 @@ public partial class ODataSerializerContext
private ODataQueryContext _queryContext;
private SelectExpandClause _selectExpandClause;
private bool _isSelectExpandClauseSet;
+ private bool? _isUntyped;
+ private bool? _isDeltaOfT;
///
/// Initializes a new instance of the class.
@@ -159,6 +165,34 @@ internal ODataQueryContext QueryContext
///
public ODataPath Path { get; set; }
+ internal Type Type { get; set; }
+
+ internal bool IsUntyped
+ {
+ get
+ { if (_isUntyped == null)
+ {
+ _isUntyped = typeof(IEdmObject).IsAssignableFrom(Type);
+ }
+
+ return _isUntyped.Value;
+ }
+ }
+
+ internal bool IsDeltaOfT
+ {
+ get
+ {
+ if (_isDeltaOfT == null)
+ {
+ _isDeltaOfT = Type != null && TypeHelper.IsGenericType(Type) && (Type.GetGenericTypeDefinition() == typeof(DeltaSet<>) ||
+ Type.GetGenericTypeDefinition() == typeof(Delta<>) || Type.GetGenericTypeDefinition() == typeof(DeltaDeletedEntityObject<>));
+ }
+
+ return _isDeltaOfT.Value;
+ }
+ }
+
///
/// Gets or sets the root element name which is used when writing primitive and enum types
///
@@ -296,6 +330,11 @@ internal IEdmTypeReference GetEdmType(object instance, Type type)
}
else
{
+ if (typeof(IDeltaSet).IsAssignableFrom(type))
+ {
+ return EdmLibHelpers.ToEdmTypeReference(Path.EdmType, isNullable: false);
+ }
+
if (Model == null)
{
throw Error.InvalidOperation(SRResources.RequestMustHaveModel);
@@ -308,7 +347,15 @@ internal IEdmTypeReference GetEdmType(object instance, Type type)
{
if (instance != null)
{
- edmType = _typeMappingCache.GetEdmType(instance.GetType(), Model);
+ TypedDelta delta = instance as TypedDelta;
+ if (delta != null)
+ {
+ edmType = _typeMappingCache.GetEdmType(delta.ExpectedClrType, Model);
+ }
+ else
+ {
+ edmType = _typeMappingCache.GetEdmType(instance.GetType(), Model);
+ }
}
if (edmType == null)
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataSerializerHelper.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataSerializerHelper.cs
new file mode 100644
index 0000000000..a130405301
--- /dev/null
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataSerializerHelper.cs
@@ -0,0 +1,108 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+
+using System.Collections.Generic;
+using Microsoft.AspNet.OData.Builder;
+using Microsoft.OData;
+using Microsoft.OData.Edm;
+
+namespace Microsoft.AspNet.OData.Formatter.Serialization
+{
+ ///
+ /// Helper class for OData Serialization
+ ///
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1053:StaticHolderTypesShouldNotHaveConstructors")]
+ internal class ODataSerializerHelper
+ {
+ internal static void AppendInstanceAnnotations(ODataResourceBase resource, ResourceContext resourceContext, object value, ODataSerializerProvider SerializerProvider)
+ {
+ IODataInstanceAnnotationContainer instanceAnnotationContainer = value as IODataInstanceAnnotationContainer;
+
+ if (instanceAnnotationContainer != null)
+ {
+ IDictionary clrAnnotations = instanceAnnotationContainer.GetResourceAnnotations();
+
+ if (clrAnnotations != null)
+ {
+ foreach (KeyValuePair annotation in clrAnnotations)
+ {
+ AddODataAnnotations(resource.InstanceAnnotations, resourceContext, annotation, SerializerProvider);
+ }
+ }
+
+ if (resource.Properties != null)
+ {
+ foreach (ODataProperty property in resource.Properties)
+ {
+ string propertyName = property.Name;
+
+ if (property.InstanceAnnotations == null)
+ {
+ property.InstanceAnnotations = new List();
+ }
+
+ IDictionary propertyAnnotations = instanceAnnotationContainer.GetPropertyAnnotations(propertyName);
+
+ if (propertyAnnotations != null)
+ {
+ foreach (KeyValuePair annotation in propertyAnnotations)
+ {
+ AddODataAnnotations(property.InstanceAnnotations, resourceContext, annotation, SerializerProvider);
+ }
+ }
+ }
+ }
+ }
+ }
+
+
+ internal static void AddODataAnnotations(ICollection InstanceAnnotations, ResourceContext resourceContext, KeyValuePair annotation, ODataSerializerProvider SerializerProvider)
+ {
+ ODataValue annotationValue = null;
+
+ if (annotation.Value != null)
+ {
+ IEdmTypeReference edmTypeReference = resourceContext.SerializerContext.GetEdmType(annotation.Value,
+ annotation.Value.GetType());
+
+ ODataEdmTypeSerializer edmTypeSerializer = GetEdmTypeSerializer(edmTypeReference, SerializerProvider);
+
+ if (edmTypeSerializer != null)
+ {
+ annotationValue = edmTypeSerializer.CreateODataValue(annotation.Value, edmTypeReference, resourceContext.SerializerContext);
+ }
+ }
+ else
+ {
+ annotationValue = new ODataNullValue();
+ }
+
+ if (annotationValue != null)
+ {
+ InstanceAnnotations.Add(new ODataInstanceAnnotation(annotation.Key, annotationValue));
+ }
+ }
+
+
+ private static ODataEdmTypeSerializer GetEdmTypeSerializer(IEdmTypeReference edmTypeReference, ODataSerializerProvider SerializerProvider)
+ {
+ ODataEdmTypeSerializer edmTypeSerializer;
+
+ if (edmTypeReference.IsCollection())
+ {
+ edmTypeSerializer = new ODataCollectionSerializer(SerializerProvider, true);
+ }
+ else if (edmTypeReference.IsStructured())
+ {
+ edmTypeSerializer = new ODataResourceValueSerializer(SerializerProvider);
+ }
+ else
+ {
+ edmTypeSerializer = SerializerProvider.GetEdmTypeSerializer(edmTypeReference);
+ }
+
+ return edmTypeSerializer;
+ }
+
+ }
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataSerializerProvider.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataSerializerProvider.cs
index a2d1089257..d6e5fc762e 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataSerializerProvider.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataSerializerProvider.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.OData.Edm;
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataSerializerProviderExtensions.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataSerializerProviderExtensions.cs
index 38008b67b1..075316af83 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataSerializerProviderExtensions.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataSerializerProviderExtensions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Diagnostics.Contracts;
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataServiceDocumentSerializer.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataServiceDocumentSerializer.cs
index b1392ce439..10bf24db2f 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataServiceDocumentSerializer.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/ODataServiceDocumentSerializer.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Runtime.Serialization;
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/SelectExpandNode.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/SelectExpandNode.cs
index 89b2aa8878..a11067de35 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/SelectExpandNode.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/SelectExpandNode.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/TypedEdmComplexObject.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/TypedEdmComplexObject.cs
index 66a690fed1..caf70c2f2f 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/TypedEdmComplexObject.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/TypedEdmComplexObject.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.OData.Edm;
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/TypedEdmEntityObject.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/TypedEdmEntityObject.cs
index 0af48af2d5..a627a8f47c 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/TypedEdmEntityObject.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/TypedEdmEntityObject.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.OData.Edm;
@@ -21,4 +25,4 @@ public TypedEdmEntityObject(object instance, IEdmEntityTypeReference edmType, IE
{
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/TypedEdmStructuredObject.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/TypedEdmStructuredObject.cs
index 7ea75f1b69..1c7f1d32d6 100644
--- a/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/TypedEdmStructuredObject.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Formatter/Serialization/TypedEdmStructuredObject.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Concurrent;
diff --git a/src/Microsoft.AspNet.OData.Shared/FunctionImportComparer.cs b/src/Microsoft.AspNet.OData.Shared/FunctionImportComparer.cs
index 5fc44c2bfb..f4a50fbcc1 100644
--- a/src/Microsoft.AspNet.OData.Shared/FunctionImportComparer.cs
+++ b/src/Microsoft.AspNet.OData.Shared/FunctionImportComparer.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/GetNextPageHelper.cs b/src/Microsoft.AspNet.OData.Shared/GetNextPageHelper.cs
index 85e45095e6..3135e2697b 100644
--- a/src/Microsoft.AspNet.OData.Shared/GetNextPageHelper.cs
+++ b/src/Microsoft.AspNet.OData.Shared/GetNextPageHelper.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/IDelta.cs b/src/Microsoft.AspNet.OData.Shared/IDelta.cs
index 30f966dda8..d07c11ff36 100644
--- a/src/Microsoft.AspNet.OData.Shared/IDelta.cs
+++ b/src/Microsoft.AspNet.OData.Shared/IDelta.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/IDeltaDeletedEntityObject.cs b/src/Microsoft.AspNet.OData.Shared/IDeltaDeletedEntityObject.cs
new file mode 100644
index 0000000000..703ad0f145
--- /dev/null
+++ b/src/Microsoft.AspNet.OData.Shared/IDeltaDeletedEntityObject.cs
@@ -0,0 +1,31 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+
+using System;
+using Microsoft.OData;
+using Microsoft.OData.Edm;
+
+namespace Microsoft.AspNet.OData
+{
+ ///
+ /// Base interface to represented a typed deleted entity object
+ ///
+ public interface IDeltaDeletedEntityObject
+ {
+ ///
+ /// The id of the deleted entity (same as the odata.id returned or computed when calling GET on resource), which may be absolute or relative.
+ ///
+ Uri Id { get; set; }
+
+ ///
+ /// Optional. Either deleted, if the entity was deleted (destroyed), or changed if the entity was removed from membership in the result (i.e., due to a data change).
+ ///
+ DeltaDeletedEntryReason? Reason { get; set; }
+
+ ///
+ /// The navigation source of the deleted entity. If null, then the deleted entity is from the current feed.
+ ///
+ IEdmNavigationSource NavigationSource { get; set; }
+
+ }
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/IDeltaSet.cs b/src/Microsoft.AspNet.OData.Shared/IDeltaSet.cs
new file mode 100644
index 0000000000..a09a4f127e
--- /dev/null
+++ b/src/Microsoft.AspNet.OData.Shared/IDeltaSet.cs
@@ -0,0 +1,16 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+
+namespace Microsoft.AspNet.OData
+{
+ ///
+ /// Basic interface to reperesent a deltaset which is a collection of Deltas.
+ /// This is being implemented by Deltaset{TStructuralType}. Since its being implementd by a gemeric type and
+ /// since we need to check in a few places(like deserializer) where the object is a DeltaSet and the {TStructuralType} is not available,
+ /// we need a marker interface which can be used in these checks.
+ ///
+ public interface IDeltaSet
+ {
+
+ }
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/IDeltaSetItem.cs b/src/Microsoft.AspNet.OData.Shared/IDeltaSetItem.cs
new file mode 100644
index 0000000000..39ea15fb06
--- /dev/null
+++ b/src/Microsoft.AspNet.OData.Shared/IDeltaSetItem.cs
@@ -0,0 +1,32 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+
+using Microsoft.AspNet.OData.Builder;
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using System.Text;
+
+namespace Microsoft.AspNet.OData
+{
+ ///
+ /// Basic Interface for representing a delta item like delta, deletedentity etc
+ ///
+ public interface IDeltaSetItem
+ {
+ ///
+ /// Entry or Deleted Entry for Delta Set Item
+ ///
+ EdmDeltaEntityKind DeltaKind { get; }
+
+ ///
+ /// Annotation container to hold Transient Instance Annotations
+ ///
+ IODataInstanceAnnotationContainer TransientInstanceAnnotationContainer { get; set; }
+
+ ///
+ /// Container to hold ODataId
+ ///
+ ODataIdContainer ODataIdContainer { get; set; }
+ }
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/IEdmChangedObject.cs b/src/Microsoft.AspNet.OData.Shared/IEdmChangedObject.cs
index 6dc0b68552..2857744988 100644
--- a/src/Microsoft.AspNet.OData.Shared/IEdmChangedObject.cs
+++ b/src/Microsoft.AspNet.OData.Shared/IEdmChangedObject.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
namespace Microsoft.AspNet.OData
{
@@ -15,4 +19,4 @@ public interface IEdmChangedObject : IEdmStructuredObject
///
EdmDeltaEntityKind DeltaKind { get; }
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/IEdmComplexObject.cs b/src/Microsoft.AspNet.OData.Shared/IEdmComplexObject.cs
index a91d9aceeb..4f1f74ce24 100644
--- a/src/Microsoft.AspNet.OData.Shared/IEdmComplexObject.cs
+++ b/src/Microsoft.AspNet.OData.Shared/IEdmComplexObject.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.OData.Edm;
diff --git a/src/Microsoft.AspNet.OData.Shared/IEdmDeltaDeletedEntityObject.cs b/src/Microsoft.AspNet.OData.Shared/IEdmDeltaDeletedEntityObject.cs
index ed673e5405..6723f353ff 100644
--- a/src/Microsoft.AspNet.OData.Shared/IEdmDeltaDeletedEntityObject.cs
+++ b/src/Microsoft.AspNet.OData.Shared/IEdmDeltaDeletedEntityObject.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.OData;
diff --git a/src/Microsoft.AspNet.OData.Shared/IEdmDeltaDeletedLink.cs b/src/Microsoft.AspNet.OData.Shared/IEdmDeltaDeletedLink.cs
index e1734866d6..da20e9442a 100644
--- a/src/Microsoft.AspNet.OData.Shared/IEdmDeltaDeletedLink.cs
+++ b/src/Microsoft.AspNet.OData.Shared/IEdmDeltaDeletedLink.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
namespace Microsoft.AspNet.OData
{
diff --git a/src/Microsoft.AspNet.OData.Shared/IEdmDeltaLink.cs b/src/Microsoft.AspNet.OData.Shared/IEdmDeltaLink.cs
index a03f8af47c..69cc1dbaeb 100644
--- a/src/Microsoft.AspNet.OData.Shared/IEdmDeltaLink.cs
+++ b/src/Microsoft.AspNet.OData.Shared/IEdmDeltaLink.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
namespace Microsoft.AspNet.OData
{
diff --git a/src/Microsoft.AspNet.OData.Shared/IEdmDeltaLinkBase.cs b/src/Microsoft.AspNet.OData.Shared/IEdmDeltaLinkBase.cs
index dde7174cce..91259c9f42 100644
--- a/src/Microsoft.AspNet.OData.Shared/IEdmDeltaLinkBase.cs
+++ b/src/Microsoft.AspNet.OData.Shared/IEdmDeltaLinkBase.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
diff --git a/src/Microsoft.AspNet.OData.Shared/IEdmEntityObject.cs b/src/Microsoft.AspNet.OData.Shared/IEdmEntityObject.cs
index e1f7ee8a10..4411d0f299 100644
--- a/src/Microsoft.AspNet.OData.Shared/IEdmEntityObject.cs
+++ b/src/Microsoft.AspNet.OData.Shared/IEdmEntityObject.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.OData.Edm;
diff --git a/src/Microsoft.AspNet.OData.Shared/IEdmEnumObject.cs b/src/Microsoft.AspNet.OData.Shared/IEdmEnumObject.cs
index 7441ec5a30..beff4c2874 100644
--- a/src/Microsoft.AspNet.OData.Shared/IEdmEnumObject.cs
+++ b/src/Microsoft.AspNet.OData.Shared/IEdmEnumObject.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Diagnostics.CodeAnalysis;
diff --git a/src/Microsoft.AspNet.OData.Shared/IEdmObject.cs b/src/Microsoft.AspNet.OData.Shared/IEdmObject.cs
index dd26d9f582..7e51e34282 100644
--- a/src/Microsoft.AspNet.OData.Shared/IEdmObject.cs
+++ b/src/Microsoft.AspNet.OData.Shared/IEdmObject.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Diagnostics.CodeAnalysis;
using Microsoft.OData.Edm;
diff --git a/src/Microsoft.AspNet.OData.Shared/IEdmStructuredObject.cs b/src/Microsoft.AspNet.OData.Shared/IEdmStructuredObject.cs
index e4810ca198..fc199328e4 100644
--- a/src/Microsoft.AspNet.OData.Shared/IEdmStructuredObject.cs
+++ b/src/Microsoft.AspNet.OData.Shared/IEdmStructuredObject.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Diagnostics.CodeAnalysis;
using Microsoft.OData.Edm;
diff --git a/src/Microsoft.AspNet.OData.Shared/IODataAPIHandler.cs b/src/Microsoft.AspNet.OData.Shared/IODataAPIHandler.cs
new file mode 100644
index 0000000000..dc63ad5370
--- /dev/null
+++ b/src/Microsoft.AspNet.OData.Shared/IODataAPIHandler.cs
@@ -0,0 +1,15 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+
+namespace Microsoft.AspNet.OData
+{
+ ///
+ /// Base Interface for ODataAPIHandler.
+ /// This is being implemented by ODataAPIHandler{TStructuralType} which has a method returning nested ODataApiHandler.
+ /// A generic empty interface is needed since the nestedpatch handler will be of different type.
+ ///
+ public interface IODataAPIHandler
+ {
+
+ }
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/IPerRouteContainer.cs b/src/Microsoft.AspNet.OData.Shared/IPerRouteContainer.cs
index 05ad3377bb..78a4e89393 100644
--- a/src/Microsoft.AspNet.OData.Shared/IPerRouteContainer.cs
+++ b/src/Microsoft.AspNet.OData.Shared/IPerRouteContainer.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.OData;
diff --git a/src/Microsoft.AspNet.OData.Shared/Interfaces/IWebApiActionDescriptor.cs b/src/Microsoft.AspNet.OData.Shared/Interfaces/IWebApiActionDescriptor.cs
index a6001ac03b..cba0b19131 100644
--- a/src/Microsoft.AspNet.OData.Shared/Interfaces/IWebApiActionDescriptor.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Interfaces/IWebApiActionDescriptor.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Interfaces/IWebApiActionMap.cs b/src/Microsoft.AspNet.OData.Shared/Interfaces/IWebApiActionMap.cs
index 26eae99504..8b09ea169c 100644
--- a/src/Microsoft.AspNet.OData.Shared/Interfaces/IWebApiActionMap.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Interfaces/IWebApiActionMap.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
namespace Microsoft.AspNet.OData.Interfaces
{
@@ -19,5 +23,12 @@ internal interface IWebApiActionMap
/// The key.
/// True if the key exist; false otherwise.
bool Contains(string name);
+
+ ///
+ /// Gets the action descriptor of the specified action
+ ///
+ /// The name of the action
+ /// The if it exists, otherwise null
+ IWebApiActionDescriptor GetActionDescriptor(string actionName);
}
}
diff --git a/src/Microsoft.AspNet.OData.Shared/Interfaces/IWebApiAssembliesResolver.cs b/src/Microsoft.AspNet.OData.Shared/Interfaces/IWebApiAssembliesResolver.cs
index 289035a8dd..ccda04f265 100644
--- a/src/Microsoft.AspNet.OData.Shared/Interfaces/IWebApiAssembliesResolver.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Interfaces/IWebApiAssembliesResolver.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Reflection;
diff --git a/src/Microsoft.AspNet.OData.Shared/Interfaces/IWebApiContext.cs b/src/Microsoft.AspNet.OData.Shared/Interfaces/IWebApiContext.cs
index 0406ca70e6..ef21e904bd 100644
--- a/src/Microsoft.AspNet.OData.Shared/Interfaces/IWebApiContext.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Interfaces/IWebApiContext.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Interfaces/IWebApiControllerContext.cs b/src/Microsoft.AspNet.OData.Shared/Interfaces/IWebApiControllerContext.cs
index f5f07f244e..2afb0ab2a5 100644
--- a/src/Microsoft.AspNet.OData.Shared/Interfaces/IWebApiControllerContext.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Interfaces/IWebApiControllerContext.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using Microsoft.AspNet.OData.Routing.Conventions;
diff --git a/src/Microsoft.AspNet.OData.Shared/Interfaces/IWebApiHeaders.cs b/src/Microsoft.AspNet.OData.Shared/Interfaces/IWebApiHeaders.cs
index 03e7523f24..8e95cc99bf 100644
--- a/src/Microsoft.AspNet.OData.Shared/Interfaces/IWebApiHeaders.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Interfaces/IWebApiHeaders.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Interfaces/IWebApiOptions.cs b/src/Microsoft.AspNet.OData.Shared/Interfaces/IWebApiOptions.cs
index 8e082dbe48..cd53a6527f 100644
--- a/src/Microsoft.AspNet.OData.Shared/Interfaces/IWebApiOptions.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Interfaces/IWebApiOptions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.OData;
diff --git a/src/Microsoft.AspNet.OData.Shared/Interfaces/IWebApiRequestMessage.cs b/src/Microsoft.AspNet.OData.Shared/Interfaces/IWebApiRequestMessage.cs
index 9a01c41f6a..76c17c186a 100644
--- a/src/Microsoft.AspNet.OData.Shared/Interfaces/IWebApiRequestMessage.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Interfaces/IWebApiRequestMessage.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Interfaces/IWebApiUrlHelper.cs b/src/Microsoft.AspNet.OData.Shared/Interfaces/IWebApiUrlHelper.cs
index a4c154642b..273c89f104 100644
--- a/src/Microsoft.AspNet.OData.Shared/Interfaces/IWebApiUrlHelper.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Interfaces/IWebApiUrlHelper.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using Microsoft.AspNet.OData.Routing;
diff --git a/src/Microsoft.AspNet.OData.Shared/MetadataController.cs b/src/Microsoft.AspNet.OData.Shared/MetadataController.cs
index 857f706637..b75e803fe9 100644
--- a/src/Microsoft.AspNet.OData.Shared/MetadataController.cs
+++ b/src/Microsoft.AspNet.OData.Shared/MetadataController.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Microsoft.AspNet.OData.Shared.projitems b/src/Microsoft.AspNet.OData.Shared/Microsoft.AspNet.OData.Shared.projitems
index f424f40b16..21e4d3dd64 100644
--- a/src/Microsoft.AspNet.OData.Shared/Microsoft.AspNet.OData.Shared.projitems
+++ b/src/Microsoft.AspNet.OData.Shared/Microsoft.AspNet.OData.Shared.projitems
@@ -53,12 +53,18 @@
+
+
+
+
+
+
@@ -71,13 +77,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -259,6 +283,7 @@
+
diff --git a/src/Microsoft.AspNet.OData.Shared/NavigationPath.cs b/src/Microsoft.AspNet.OData.Shared/NavigationPath.cs
new file mode 100644
index 0000000000..4b32c53b14
--- /dev/null
+++ b/src/Microsoft.AspNet.OData.Shared/NavigationPath.cs
@@ -0,0 +1,98 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using Microsoft.OData.UriParser;
+
+namespace Microsoft.AspNet.OData
+{
+ ///
+ /// Navigation Path of an OData ID
+ ///
+ public class NavigationPath
+ {
+ private string navigationPathName;
+ private ReadOnlyCollection _pathSegments;
+ private ConcurrentDictionary _pathItemCache = new ConcurrentDictionary();
+
+ ///
+ /// Constructor which takes and odataId and creates PathItems
+ ///
+ public NavigationPath()
+ {
+
+ }
+
+ ///
+ /// Constructor which takes and odataId and creates PathItems
+ ///
+ /// ODataId in string format
+ /// Pathsegment collection
+ public NavigationPath(string navigationPath, ReadOnlyCollection pathSegments)
+ {
+ navigationPathName = navigationPath;
+ _pathSegments = pathSegments;
+ }
+
+
+ ///
+ /// NavigationPath/ODataId in string
+ ///
+ public string NavigationPathName { get { return navigationPathName; } }
+
+ ///
+ /// To Get ODataId in Parsed format
+ ///
+ /// Array of PathItems
+ public PathItem[] GetNavigationPathItems()
+ {
+ PathItem[] pathItems;
+ if(!_pathItemCache.TryGetValue(navigationPathName, out pathItems))
+ {
+ if (_pathSegments != null)
+ {
+ pathItems = ParseODataId();
+ _pathItemCache.TryAdd(navigationPathName, pathItems);
+ }
+ }
+
+ return pathItems;
+ }
+
+ private PathItem[] ParseODataId()
+ {
+ List pathItems = new List();
+ PathItem currentPathItem = null;
+
+ foreach (ODataPathSegment segment in _pathSegments)
+ {
+ if (segment is EntitySetSegment || segment is NavigationPropertySegment)
+ {
+ pathItems.Add(new PathItem());
+ currentPathItem = pathItems.Last();
+ currentPathItem.Name = segment.Identifier;
+ }
+ else if(segment is TypeSegment)
+ {
+ currentPathItem.IsCastType = true;
+ currentPathItem.CastTypeName = segment.Identifier;
+ }
+ else if (segment is KeySegment keySegment)
+ {
+ currentPathItem.KeyProperties = new Dictionary();
+
+ foreach(KeyValuePair key in keySegment.Keys)
+ {
+ currentPathItem.KeyProperties.Add(key.Key, key.Value);
+ }
+ }
+
+ }
+
+ return pathItems.ToArray();
+ }
+ }
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/NavigationPropertyQueryableConfiguration.cs b/src/Microsoft.AspNet.OData.Shared/NavigationPropertyQueryableConfiguration.cs
index dfdc4087e2..c932e998ad 100644
--- a/src/Microsoft.AspNet.OData.Shared/NavigationPropertyQueryableConfiguration.cs
+++ b/src/Microsoft.AspNet.OData.Shared/NavigationPropertyQueryableConfiguration.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Builder;
diff --git a/src/Microsoft.AspNet.OData.Shared/NavigationPropertyQueryableConfigurationAnnotation.cs b/src/Microsoft.AspNet.OData.Shared/NavigationPropertyQueryableConfigurationAnnotation.cs
index 22086717cb..7b49d86aa3 100644
--- a/src/Microsoft.AspNet.OData.Shared/NavigationPropertyQueryableConfigurationAnnotation.cs
+++ b/src/Microsoft.AspNet.OData.Shared/NavigationPropertyQueryableConfigurationAnnotation.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
namespace Microsoft.AspNet.OData
{
diff --git a/src/Microsoft.AspNet.OData.Shared/NonValidatingParameterBindingAttribute.cs b/src/Microsoft.AspNet.OData.Shared/NonValidatingParameterBindingAttribute.cs
index 5e850be060..db5c851af7 100644
--- a/src/Microsoft.AspNet.OData.Shared/NonValidatingParameterBindingAttribute.cs
+++ b/src/Microsoft.AspNet.OData.Shared/NonValidatingParameterBindingAttribute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
namespace Microsoft.AspNet.OData
{
diff --git a/src/Microsoft.AspNet.OData.Shared/NullEdmComplexObject.cs b/src/Microsoft.AspNet.OData.Shared/NullEdmComplexObject.cs
index e864bb0d96..4e5102caad 100644
--- a/src/Microsoft.AspNet.OData.Shared/NullEdmComplexObject.cs
+++ b/src/Microsoft.AspNet.OData.Shared/NullEdmComplexObject.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Common;
using Microsoft.OData.Edm;
diff --git a/src/Microsoft.AspNet.OData.Shared/ODataAPIHandler.cs b/src/Microsoft.AspNet.OData.Shared/ODataAPIHandler.cs
new file mode 100644
index 0000000000..739c568969
--- /dev/null
+++ b/src/Microsoft.AspNet.OData.Shared/ODataAPIHandler.cs
@@ -0,0 +1,50 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+
+using System.Collections.Generic;
+
+namespace Microsoft.AspNet.OData
+{
+ ///
+ /// Handler Class to handle users methods for create, delete and update.
+ /// This is the handler for data modification where there is a CLR type.
+ ///
+ public abstract class ODataAPIHandler: IODataAPIHandler where TStructuralType : class
+ {
+ ///
+ /// TryCreate method to create a new object.
+ ///
+ /// TheKey value pair of the objecct to be created. Optional
+ /// The created object (CLR or Typeless)
+ /// Any error message in case of an exception
+ /// The status of the TryCreate method
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "2#")]
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "1#")]
+ public abstract ODataAPIResponseStatus TryCreate(IDictionary keyValues, out TStructuralType createdObject, out string errorMessage);
+
+ ///
+ /// TryGet method which tries to get the Origignal object based on a keyvalues.
+ ///
+ /// Key value pair for the entity keys
+ /// Object to return
+ /// Any error message in case of an exception
+ /// The status of the TryGet method
+ public abstract ODataAPIResponseStatus TryGet(IDictionary keyValues, out TStructuralType originalObject, out string errorMessage);
+
+ ///
+ /// TryDelete Method which will delete the object based on keyvalue pairs.
+ ///
+ ///
+ ///
+ /// The status of the TryGet method
+ public abstract ODataAPIResponseStatus TryDelete(IDictionary keyValues, out string errorMessage);
+
+ ///
+ /// Get the ODataAPIHandler for the nested type
+ ///
+ /// Parent instance.
+ /// The name of the navigation property for the handler
+ /// The type of Nested ODataAPIHandler
+ public abstract IODataAPIHandler GetNestedHandler(TStructuralType parent, string navigationPropertyName);
+ }
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/ODataAPIHandlerFactory.cs b/src/Microsoft.AspNet.OData.Shared/ODataAPIHandlerFactory.cs
new file mode 100644
index 0000000000..507536ba34
--- /dev/null
+++ b/src/Microsoft.AspNet.OData.Shared/ODataAPIHandlerFactory.cs
@@ -0,0 +1,18 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+
+namespace Microsoft.AspNet.OData
+{
+ ///
+ /// Factory class for ODataAPIHandlers
+ ///
+ public abstract class ODataAPIHandlerFactory
+ {
+ ///
+ /// Get the handler depending on navigationpath
+ ///
+ /// Navigation path corresponding to an odataid
+ ///
+ public abstract IODataAPIHandler GetHandler(NavigationPath navigationPath);
+ }
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/ODataAPIResponseStatus.cs b/src/Microsoft.AspNet.OData.Shared/ODataAPIResponseStatus.cs
new file mode 100644
index 0000000000..5b24274d38
--- /dev/null
+++ b/src/Microsoft.AspNet.OData.Shared/ODataAPIResponseStatus.cs
@@ -0,0 +1,24 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+
+namespace Microsoft.AspNet.OData
+{
+ ///
+ /// Enum for Patch Status
+ ///
+ public enum ODataAPIResponseStatus
+ {
+ ///
+ /// Success Status
+ ///
+ Success,
+ ///
+ /// Failure Status
+ ///
+ Failure,
+ ///
+ /// Resource Not Found
+ ///
+ NotFound
+ }
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/ODataActionParameters.cs b/src/Microsoft.AspNet.OData.Shared/ODataActionParameters.cs
index 0a082fa4bf..2e2d5048b3 100644
--- a/src/Microsoft.AspNet.OData.Shared/ODataActionParameters.cs
+++ b/src/Microsoft.AspNet.OData.Shared/ODataActionParameters.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
@@ -16,4 +20,4 @@ namespace Microsoft.AspNet.OData
public class ODataActionParameters : Dictionary
{
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/ODataController.cs b/src/Microsoft.AspNet.OData.Shared/ODataController.cs
index 02132e9bc7..1ce305c9f2 100644
--- a/src/Microsoft.AspNet.OData.Shared/ODataController.cs
+++ b/src/Microsoft.AspNet.OData.Shared/ODataController.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
namespace Microsoft.AspNet.OData
{
diff --git a/src/Microsoft.AspNet.OData.Shared/ODataEdmAPIHandlerFactory.cs b/src/Microsoft.AspNet.OData.Shared/ODataEdmAPIHandlerFactory.cs
new file mode 100644
index 0000000000..1a772d192a
--- /dev/null
+++ b/src/Microsoft.AspNet.OData.Shared/ODataEdmAPIHandlerFactory.cs
@@ -0,0 +1,18 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+
+namespace Microsoft.AspNet.OData
+{
+ ///
+ /// Factory class for ODataAPIHandlers for typeless entities
+ ///
+ public abstract class ODataEdmAPIHandlerFactory
+ {
+ ///
+ /// Get the handler depending on navigationpath
+ ///
+ /// Navigation path corresponding to an odataid
+ ///
+ public abstract EdmODataAPIHandler GetHandler(NavigationPath navigationPath);
+ }
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/ODataIdContainer.cs b/src/Microsoft.AspNet.OData.Shared/ODataIdContainer.cs
new file mode 100644
index 0000000000..75f397cb9f
--- /dev/null
+++ b/src/Microsoft.AspNet.OData.Shared/ODataIdContainer.cs
@@ -0,0 +1,16 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+
+namespace Microsoft.AspNet.OData
+{
+ ///
+ /// Sealed class to hold ODataID in parsed format, it will be used by POCO objects as well as Delta{TStructuralType}
+ ///
+ public sealed class ODataIdContainer
+ {
+ ///
+ /// The Navigation path corresponding to the ODataId
+ ///
+ public NavigationPath ODataIdNavigationPath { set; get; }
+ }
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/ODataNullValueMessageHandler.cs b/src/Microsoft.AspNet.OData.Shared/ODataNullValueMessageHandler.cs
index a60d571dc3..561f00e574 100644
--- a/src/Microsoft.AspNet.OData.Shared/ODataNullValueMessageHandler.cs
+++ b/src/Microsoft.AspNet.OData.Shared/ODataNullValueMessageHandler.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.ObjectModel;
using System.Net;
diff --git a/src/Microsoft.AspNet.OData.Shared/ODataQueryContext.cs b/src/Microsoft.AspNet.OData.Shared/ODataQueryContext.cs
index e383f1691c..a34aacfee2 100644
--- a/src/Microsoft.AspNet.OData.Shared/ODataQueryContext.cs
+++ b/src/Microsoft.AspNet.OData.Shared/ODataQueryContext.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/ODataQueryContextExtensions.cs b/src/Microsoft.AspNet.OData.Shared/ODataQueryContextExtensions.cs
index 04f1e8f73a..9914221ec2 100644
--- a/src/Microsoft.AspNet.OData.Shared/ODataQueryContextExtensions.cs
+++ b/src/Microsoft.AspNet.OData.Shared/ODataQueryContextExtensions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Linq;
using Microsoft.AspNet.OData.Query;
@@ -48,4 +52,4 @@ public static SkipTokenQueryValidator GetSkipTokenQueryValidator(this ODataQuery
return context.RequestContainer.GetRequiredService();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/ODataQueryParameterBindingAttribute.cs b/src/Microsoft.AspNet.OData.Shared/ODataQueryParameterBindingAttribute.cs
index 3aa5cfd598..b538ceaa58 100644
--- a/src/Microsoft.AspNet.OData.Shared/ODataQueryParameterBindingAttribute.cs
+++ b/src/Microsoft.AspNet.OData.Shared/ODataQueryParameterBindingAttribute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Diagnostics.Contracts;
diff --git a/src/Microsoft.AspNet.OData.Shared/ODataSwaggerConverter.cs b/src/Microsoft.AspNet.OData.Shared/ODataSwaggerConverter.cs
index b345c68177..f6c18fbb1a 100644
--- a/src/Microsoft.AspNet.OData.Shared/ODataSwaggerConverter.cs
+++ b/src/Microsoft.AspNet.OData.Shared/ODataSwaggerConverter.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Diagnostics.CodeAnalysis;
diff --git a/src/Microsoft.AspNet.OData.Shared/ODataSwaggerUtilities.cs b/src/Microsoft.AspNet.OData.Shared/ODataSwaggerUtilities.cs
index 07f33e0a83..d91f075292 100644
--- a/src/Microsoft.AspNet.OData.Shared/ODataSwaggerUtilities.cs
+++ b/src/Microsoft.AspNet.OData.Shared/ODataSwaggerUtilities.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Diagnostics.Contracts;
diff --git a/src/Microsoft.AspNet.OData.Shared/ODataUntypedActionParameters.cs b/src/Microsoft.AspNet.OData.Shared/ODataUntypedActionParameters.cs
index f64f15736e..599d4b8e94 100644
--- a/src/Microsoft.AspNet.OData.Shared/ODataUntypedActionParameters.cs
+++ b/src/Microsoft.AspNet.OData.Shared/ODataUntypedActionParameters.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
diff --git a/src/Microsoft.AspNet.OData.Shared/ODataUriFunctions.cs b/src/Microsoft.AspNet.OData.Shared/ODataUriFunctions.cs
index a7f599fe5a..77ab54d2b3 100644
--- a/src/Microsoft.AspNet.OData.Shared/ODataUriFunctions.cs
+++ b/src/Microsoft.AspNet.OData.Shared/ODataUriFunctions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Reflection;
diff --git a/src/Microsoft.AspNet.OData.Shared/PageResult.cs b/src/Microsoft.AspNet.OData.Shared/PageResult.cs
index 409d5e1ba2..b3233471b9 100644
--- a/src/Microsoft.AspNet.OData.Shared/PageResult.cs
+++ b/src/Microsoft.AspNet.OData.Shared/PageResult.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Runtime.Serialization;
diff --git a/src/Microsoft.AspNet.OData.Shared/PageResultOfT.cs b/src/Microsoft.AspNet.OData.Shared/PageResultOfT.cs
index 5f1e87d594..d19b7147f1 100644
--- a/src/Microsoft.AspNet.OData.Shared/PageResultOfT.cs
+++ b/src/Microsoft.AspNet.OData.Shared/PageResultOfT.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections;
@@ -65,4 +69,4 @@ IEnumerator IEnumerable.GetEnumerator()
return Items.GetEnumerator();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/PathItem.cs b/src/Microsoft.AspNet.OData.Shared/PathItem.cs
new file mode 100644
index 0000000000..aa47fcf535
--- /dev/null
+++ b/src/Microsoft.AspNet.OData.Shared/PathItem.cs
@@ -0,0 +1,33 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+
+using System.Collections.Generic;
+
+namespace Microsoft.AspNet.OData
+{
+ ///
+ /// Class to hold the PathItem Name and its keyproperties
+ ///
+ public class PathItem
+ {
+ ///
+ /// Name of the Path Item (eg: entity name, entity set name)
+ ///
+ public string Name { internal set; get; }
+
+ ///
+ /// Whether the PathItem is a cast segment
+ ///
+ public bool IsCastType { internal set; get; }
+
+ ///
+ /// If the item is a cast segment, Name of the Path Item (eg: derived entity name, entity set name)
+ ///
+ public string CastTypeName { internal set; get; }
+
+ ///
+ /// List of Key properties of that entity
+ ///
+ public Dictionary KeyProperties { internal set; get; }
+ }
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/PerRouteContainerBase.cs b/src/Microsoft.AspNet.OData.Shared/PerRouteContainerBase.cs
index bfc9bf855a..2b5bbee9b7 100644
--- a/src/Microsoft.AspNet.OData.Shared/PerRouteContainerBase.cs
+++ b/src/Microsoft.AspNet.OData.Shared/PerRouteContainerBase.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/PropertyAccessor.cs b/src/Microsoft.AspNet.OData.Shared/PropertyAccessor.cs
index 0d73a5826e..8b6ea43385 100644
--- a/src/Microsoft.AspNet.OData.Shared/PropertyAccessor.cs
+++ b/src/Microsoft.AspNet.OData.Shared/PropertyAccessor.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Reflection;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/AllowedArithmeticOperators.cs b/src/Microsoft.AspNet.OData.Shared/Query/AllowedArithmeticOperators.cs
index c0aecc2512..d2f26d0222 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/AllowedArithmeticOperators.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/AllowedArithmeticOperators.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/AllowedFunctions.cs b/src/Microsoft.AspNet.OData.Shared/Query/AllowedFunctions.cs
index 1e17858acd..477036c517 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/AllowedFunctions.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/AllowedFunctions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
@@ -166,4 +170,4 @@ public enum AllowedFunctions
///
AllFunctions = AllStringFunctions | AllDateTimeFunctions | AllMathFunctions | Cast | IsOf | Any | All
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/AllowedLogicalOperators.cs b/src/Microsoft.AspNet.OData.Shared/Query/AllowedLogicalOperators.cs
index 44c19fba8f..860c22ef50 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/AllowedLogicalOperators.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/AllowedLogicalOperators.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/AllowedQueryOptions.cs b/src/Microsoft.AspNet.OData.Shared/Query/AllowedQueryOptions.cs
index d17e22b202..32cd847633 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/AllowedQueryOptions.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/AllowedQueryOptions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/ApplyQueryOption.cs b/src/Microsoft.AspNet.OData.Shared/Query/ApplyQueryOption.cs
index c63920c785..a65a817fb9 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/ApplyQueryOption.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/ApplyQueryOption.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Diagnostics.Contracts;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/CountAttribute.cs b/src/Microsoft.AspNet.OData.Shared/Query/CountAttribute.cs
index 8330280384..91a83d5141 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/CountAttribute.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/CountAttribute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/CountQueryOption.cs b/src/Microsoft.AspNet.OData.Shared/Query/CountQueryOption.cs
index a2ce501a7c..401306f3a6 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/CountQueryOption.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/CountQueryOption.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/DefaultQuerySettings.cs b/src/Microsoft.AspNet.OData.Shared/Query/DefaultQuerySettings.cs
index 67685a2826..89c57cb0f7 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/DefaultQuerySettings.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/DefaultQuerySettings.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/DefaultSkipTokenHandler.cs b/src/Microsoft.AspNet.OData.Shared/Query/DefaultSkipTokenHandler.cs
index 3042610b49..c626748b8d 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/DefaultSkipTokenHandler.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/DefaultSkipTokenHandler.cs
@@ -1,5 +1,10 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
+
using System;
using System.Collections.Generic;
using System.Diagnostics;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/ExpandAttribute.cs b/src/Microsoft.AspNet.OData.Shared/Query/ExpandAttribute.cs
index 94195e181d..8e521d141f 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/ExpandAttribute.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/ExpandAttribute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/ExpandConfiguration.cs b/src/Microsoft.AspNet.OData.Shared/Query/ExpandConfiguration.cs
index 3ea1dae5be..b6c457774b 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/ExpandConfiguration.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/ExpandConfiguration.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
namespace Microsoft.AspNet.OData.Query
{
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/AggregationBinder.cs b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/AggregationBinder.cs
index 8498cf2b7d..5a0d86cdb1 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/AggregationBinder.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/AggregationBinder.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/AggregationPropertyContainer.cs b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/AggregationPropertyContainer.cs
index d34f990eb4..db85d6a4cb 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/AggregationPropertyContainer.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/AggregationPropertyContainer.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/ClrCanonicalFunctions.cs b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/ClrCanonicalFunctions.cs
index bbd1fd5cee..e3bf6cc945 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/ClrCanonicalFunctions.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/ClrCanonicalFunctions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/ClrSafeFunctions.cs b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/ClrSafeFunctions.cs
index b7e30c5ce0..38c2545a51 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/ClrSafeFunctions.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/ClrSafeFunctions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Diagnostics.Contracts;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/ComputeBinder.cs b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/ComputeBinder.cs
index 588b584568..5284075759 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/ComputeBinder.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/ComputeBinder.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/DynamicTypeWrapper.cs b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/DynamicTypeWrapper.cs
index f9ab8c295a..ac1944191d 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/DynamicTypeWrapper.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/DynamicTypeWrapper.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/DynamicTypeWrapperConverter.cs b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/DynamicTypeWrapperConverter.cs
index 6bf0bdc674..52fbd887d2 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/DynamicTypeWrapperConverter.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/DynamicTypeWrapperConverter.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Diagnostics.Contracts;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/ExpressionBinderBase.cs b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/ExpressionBinderBase.cs
index 47245a6fe1..698ccfa8c2 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/ExpressionBinderBase.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/ExpressionBinderBase.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections;
@@ -42,7 +46,9 @@ public abstract class ExpressionBinderBase
internal static readonly Expression ZeroConstant = Expression.Constant(0);
internal static readonly MethodInfo EnumTryParseMethod = typeof(Enum).GetMethods()
- .Single(m => m.Name == "TryParse" && m.GetParameters().Length == 2);
+ .Single(m => m.Name.Equals("TryParse", StringComparison.Ordinal)
+ && m.GetParameters().Length == 2
+ && m.GetParameters()[0].ParameterType.Equals(typeof(string)));
internal static readonly Dictionary BinaryOperatorMapping = new Dictionary
{
@@ -134,11 +140,11 @@ internal Expression CreateBinaryExpression(BinaryOperatorKind binaryOperator, Ex
if (leftUnderlyingType == typeof(DateTime) && rightUnderlyingType == typeof(DateTimeOffset))
{
- right = DateTimeOffsetToDateTime(right);
+ right = DateTimeOffsetToDateTime(right, QuerySettings.EnableConstantParameterization);
}
else if (rightUnderlyingType == typeof(DateTime) && leftUnderlyingType == typeof(DateTimeOffset))
{
- left = DateTimeOffsetToDateTime(left);
+ left = DateTimeOffsetToDateTime(left, QuerySettings.EnableConstantParameterization);
}
if ((IsDateOrOffset(leftUnderlyingType) && IsDate(rightUnderlyingType)) ||
@@ -972,7 +978,7 @@ internal static object ExtractParameterizedConstant(Expression expression)
return null;
}
- internal static Expression DateTimeOffsetToDateTime(Expression expression)
+ internal static Expression DateTimeOffsetToDateTime(Expression expression, bool EnableConstantParameterization = false)
{
var unaryExpression = expression as UnaryExpression;
if (unaryExpression != null)
@@ -985,11 +991,26 @@ internal static Expression DateTimeOffsetToDateTime(Expression expression)
}
var parameterizedConstantValue = ExtractParameterizedConstant(expression);
var dto = parameterizedConstantValue as DateTimeOffset?;
- if (dto != null)
+ object expressionValue;
+
+ if(dto != null)
{
- expression = Expression.Constant(EdmPrimitiveHelpers.ConvertPrimitiveValue(dto.Value, typeof(DateTime)));
+ expressionValue = dto.Value;
+ }
+ else
+ {
+ expressionValue = (expression as ConstantExpression).Value;
+ }
+
+ object value = EdmPrimitiveHelpers.ConvertPrimitiveValue(expressionValue, typeof(DateTime));
+ if (EnableConstantParameterization)
+ {
+ return LinqParameterContainer.Parameterize(typeof(DateTime), value);
+ }
+ else
+ {
+ return Expression.Constant(value, typeof(DateTime));
}
- return expression;
}
internal static bool IsNullable(Type t)
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/FilterBinder.cs b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/FilterBinder.cs
index 4f808253ac..ec7d278dde 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/FilterBinder.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/FilterBinder.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections;
@@ -224,7 +228,31 @@ private Expression BindCountNode(CountNode node)
countMethod = ExpressionHelperMethods.EnumerableCountGeneric.MakeGenericMethod(elementType);
}
- // call Count() method.
+ MethodInfo whereMethod;
+ if (typeof(IQueryable).IsAssignableFrom(source.Type))
+ {
+ whereMethod = ExpressionHelperMethods.QueryableWhereGeneric.MakeGenericMethod(elementType);
+ }
+ else
+ {
+ whereMethod = ExpressionHelperMethods.EnumerableWhereGeneric.MakeGenericMethod(elementType);
+ }
+
+ // Bind the inner $filter clause within the $count segment.
+ // e.g Books?$filter=Authors/$count($filter=Id gt 1) gt 1
+ Expression filterExpression = null;
+ if (node.FilterClause != null)
+ {
+ filterExpression = BindFilterClause(this, node.FilterClause, elementType);
+
+ // The source expression looks like: $it.Authors
+ // So the generated source expression below will look like: $it.Authors.Where($it => $it.Id > 1)
+ source = Expression.Call(null, whereMethod, new[] { source, filterExpression });
+ }
+
+ // append LongCount() method.
+ // The final countExpression with the nested $filter clause will look like: $it.Authors.Where($it => $it.Id > 1).LongCount()
+ // The final countExpression without the nested $filter clause will look like: $it.Authors.LongCount()
countExpression = Expression.Call(null, countMethod, new[] { source });
if (QuerySettings.HandleNullPropagation == HandleNullPropagationOption.True)
@@ -916,7 +944,9 @@ private ParameterExpression HandleLambdaParameters(IEnumerable ra
foreach (RangeVariable rangeVariable in rangeVariables)
{
ParameterExpression parameter;
- if (!_lambdaParameters.TryGetValue(rangeVariable.Name, out parameter))
+
+ // Create a Parameter Expression for rangeVariables which are not $it Lambda parameters or $this.
+ if (!_lambdaParameters.TryGetValue(rangeVariable.Name, out parameter) && rangeVariable.Name != ODataThisParameterName)
{
// Work-around issue 481323 where UriParser yields a collection parameter type
// for primitive collections rather than the inner element type of the collection.
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/IdentityPropertyMapper.cs b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/IdentityPropertyMapper.cs
index e9613912f8..03d663f334 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/IdentityPropertyMapper.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/IdentityPropertyMapper.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
namespace Microsoft.AspNet.OData.Query.Expressions
{
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/Linq2ObjectsComparisonMethods.cs b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/Linq2ObjectsComparisonMethods.cs
index d63417ef73..f8e3fbbce5 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/Linq2ObjectsComparisonMethods.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/Linq2ObjectsComparisonMethods.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Reflection;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/LinqParameterContainer.cs b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/LinqParameterContainer.cs
index cf63f9be96..5e89985375 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/LinqParameterContainer.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/LinqParameterContainer.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Concurrent;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/ModelContainer.cs b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/ModelContainer.cs
index 6d90862071..c36a8e8b15 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/ModelContainer.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/ModelContainer.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Concurrent;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/NamedPropertyExpression.cs b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/NamedPropertyExpression.cs
index 13190d0722..3742a2b0ca 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/NamedPropertyExpression.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/NamedPropertyExpression.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Diagnostics.Contracts;
using System.Linq.Expressions;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/PropertyContainer.cs b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/PropertyContainer.cs
index 38b983ae9d..27af923a8e 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/PropertyContainer.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/PropertyContainer.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/PropertyContainer.generated.cs b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/PropertyContainer.generated.cs
index 4faea28655..fd725ecd50 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/PropertyContainer.generated.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/PropertyContainer.generated.cs
@@ -1,4 +1,11 @@
-//
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
+
+//
// This code was generated by a tool (PropertyContainer.generated.tt).
// Changes to this file may cause incorrect behavior and will be lost if the code is regenerated.
@@ -1567,4 +1574,4 @@ public override void ToDictionaryCore(Dictionary dictionary, IPr
};
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/SelectExpandBinder.cs b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/SelectExpandBinder.cs
index ae8a3bae8f..1e83b186e5 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/SelectExpandBinder.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/SelectExpandBinder.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/SelectExpandIncludedProperty.cs b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/SelectExpandIncludedProperty.cs
index 054b9c9213..3570f4df56 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/SelectExpandIncludedProperty.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/SelectExpandIncludedProperty.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Diagnostics.Contracts;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/SelectExpandPathExtensions.cs b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/SelectExpandPathExtensions.cs
index 6f47c916bd..4147ee8195 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/SelectExpandPathExtensions.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/SelectExpandPathExtensions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/SelectExpandWrapper.cs b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/SelectExpandWrapper.cs
index bfabc93021..62b2898a96 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/SelectExpandWrapper.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/SelectExpandWrapper.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/SelectExpandWrapperConverter.cs b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/SelectExpandWrapperConverter.cs
index 355754a222..a93fffce06 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/SelectExpandWrapperConverter.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/SelectExpandWrapperConverter.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Diagnostics.Contracts;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/SelectExpandWrapperOfT.cs b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/SelectExpandWrapperOfT.cs
index a12fe90dbb..d06afd4d55 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/SelectExpandWrapperOfT.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/SelectExpandWrapperOfT.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Newtonsoft.Json;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/TransformationBinderBase.cs b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/TransformationBinderBase.cs
index 19644c65b1..c5dda6175a 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/TransformationBinderBase.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/TransformationBinderBase.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Diagnostics.Contracts;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/UriFunctionsBinder.cs b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/UriFunctionsBinder.cs
index d2674c696d..1d45e81c89 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/Expressions/UriFunctionsBinder.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/Expressions/UriFunctionsBinder.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/FilterAttribute.cs b/src/Microsoft.AspNet.OData.Shared/Query/FilterAttribute.cs
index 838e336a93..9418a7654d 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/FilterAttribute.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/FilterAttribute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/FilterQueryOption.cs b/src/Microsoft.AspNet.OData.Shared/Query/FilterQueryOption.cs
index a7e1fd5f38..e2df123b8c 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/FilterQueryOption.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/FilterQueryOption.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/HandleNullPropagationOption.cs b/src/Microsoft.AspNet.OData.Shared/Query/HandleNullPropagationOption.cs
index 26a41cad36..d9622e15aa 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/HandleNullPropagationOption.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/HandleNullPropagationOption.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
namespace Microsoft.AspNet.OData.Query
{
@@ -25,4 +29,4 @@ public enum HandleNullPropagationOption
///
False = 2
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/HandleNullPropagationOptionHelper.cs b/src/Microsoft.AspNet.OData.Shared/Query/HandleNullPropagationOptionHelper.cs
index 505176f48f..245efc6091 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/HandleNullPropagationOptionHelper.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/HandleNullPropagationOptionHelper.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Diagnostics.Contracts;
using System.Linq;
@@ -109,4 +113,4 @@ internal enum DataSourceProviderKind
///
EFCore,
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/ICountOptionCollection.cs b/src/Microsoft.AspNet.OData.Shared/Query/ICountOptionCollection.cs
index 30e3267bad..36dea60a13 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/ICountOptionCollection.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/ICountOptionCollection.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/IODataQueryOptionsParser.cs b/src/Microsoft.AspNet.OData.Shared/Query/IODataQueryOptionsParser.cs
index f5da4aefc5..b8e7ce4555 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/IODataQueryOptionsParser.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/IODataQueryOptionsParser.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.IO;
using System.Threading.Tasks;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/IPropertyMapper.cs b/src/Microsoft.AspNet.OData.Shared/Query/IPropertyMapper.cs
index ba665064a3..58c9e74e96 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/IPropertyMapper.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/IPropertyMapper.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/ISelectExpandWrapper.cs b/src/Microsoft.AspNet.OData.Shared/Query/ISelectExpandWrapper.cs
index 33e5cfe333..e89c4049ec 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/ISelectExpandWrapper.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/ISelectExpandWrapper.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/ITruncatedCollection.cs b/src/Microsoft.AspNet.OData.Shared/Query/ITruncatedCollection.cs
index a40f4e3084..7edcf2a941 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/ITruncatedCollection.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/ITruncatedCollection.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/ModelBoundQuerySettings.cs b/src/Microsoft.AspNet.OData.Shared/Query/ModelBoundQuerySettings.cs
index b3cce60858..f1879c0e2c 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/ModelBoundQuerySettings.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/ModelBoundQuerySettings.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/NonFilterableAttribute.cs b/src/Microsoft.AspNet.OData.Shared/Query/NonFilterableAttribute.cs
index a0fc52fb33..58dfa65234 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/NonFilterableAttribute.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/NonFilterableAttribute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/NotCountableAttribute.cs b/src/Microsoft.AspNet.OData.Shared/Query/NotCountableAttribute.cs
index e8c4df9916..818a126c12 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/NotCountableAttribute.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/NotCountableAttribute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
@@ -13,4 +17,4 @@ namespace Microsoft.AspNet.OData.Query
public sealed class NotCountableAttribute : Attribute
{
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/NotExpandableAttribute.cs b/src/Microsoft.AspNet.OData.Shared/Query/NotExpandableAttribute.cs
index c2bf0559c9..59638ef3be 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/NotExpandableAttribute.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/NotExpandableAttribute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/NotFilterableAttribute.cs b/src/Microsoft.AspNet.OData.Shared/Query/NotFilterableAttribute.cs
index bb56547472..a1a3e57127 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/NotFilterableAttribute.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/NotFilterableAttribute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
@@ -13,4 +17,4 @@ namespace Microsoft.AspNet.OData.Query
public sealed class NotFilterableAttribute : Attribute
{
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/NotNavigableAttribute.cs b/src/Microsoft.AspNet.OData.Shared/Query/NotNavigableAttribute.cs
index 1f0534be32..843938a253 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/NotNavigableAttribute.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/NotNavigableAttribute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/NotSortableAttribute.cs b/src/Microsoft.AspNet.OData.Shared/Query/NotSortableAttribute.cs
index ad915c4fb8..b84d689d18 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/NotSortableAttribute.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/NotSortableAttribute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
@@ -13,4 +17,4 @@ namespace Microsoft.AspNet.OData.Query
public sealed class NotSortableAttribute : Attribute
{
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/ODataPathQueryBuilder.cs b/src/Microsoft.AspNet.OData.Shared/Query/ODataPathQueryBuilder.cs
new file mode 100644
index 0000000000..13b8aa860c
--- /dev/null
+++ b/src/Microsoft.AspNet.OData.Shared/Query/ODataPathQueryBuilder.cs
@@ -0,0 +1,213 @@
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.Contracts;
+using System.Linq;
+using System.Linq.Expressions;
+using System.Reflection;
+using Microsoft.OData.Edm;
+using Microsoft.OData.UriParser;
+
+namespace Microsoft.AspNet.OData.Query
+{
+
+ ///
+ /// This class transforms an based on
+ /// the key and property accesses in the segments of an
+ ///
+ internal class ODataPathQueryBuilder
+ {
+ private readonly IQueryable source;
+ private readonly Routing.ODataPath path;
+
+ ///
+ /// Creates an instance of
+ ///
+ /// The original to be transformed
+ /// The based on which to transform the
+ public ODataPathQueryBuilder(IQueryable source, Routing.ODataPath path)
+ {
+ this.source = source;
+ this.path = path;
+ }
+
+ ///
+ /// Transforms the source based on the sequence of path segments in the
+ ///
+ /// The result of the query transformtions or null if the path contained unsupported segments
+ public ODataPathQueryResult BuildQuery()
+ {
+ ODataPathQueryResult result = new ODataPathQueryResult();
+
+ IEnumerable segments = path.Segments;
+
+ IQueryable queryable = source;
+
+ ODataPathSegment firstSegment = segments.FirstOrDefault();
+
+ if (!(firstSegment is EntitySetSegment || firstSegment is SingletonSegment))
+ {
+ return null;
+ }
+
+ IEnumerable remainingSegments = segments.Skip(1);
+
+ foreach (ODataPathSegment segment in remainingSegments)
+ {
+ if (segment is KeySegment keySegment)
+ {
+ // The following block is equivalent to:
+ // filterPredicate = entity => (entity.KeyProp1 == Val1) && (entity.keyProp2 == Val2) && ...
+ ParameterExpression filterParam = Expression.Parameter(queryable.ElementType, "entity");
+ IEnumerable conditions = keySegment.Keys.Select(kvp =>
+ Expression.Equal(
+ Expression.Property(filterParam, kvp.Key),
+ Expression.Constant(kvp.Value)));
+ BinaryExpression filterBody = conditions.Aggregate((left, right) => Expression.AndAlso(left, right));
+ LambdaExpression filterPredicate = Expression.Lambda(filterBody, filterParam);
+
+ // The following statement is equivalent to:
+ // queryable = queryable.Where(entity => (entity.KeyProp1 == Val1) && (entity.KeyProp2 == Val2) ...)
+ queryable = ExpressionHelpers.Where(queryable, filterPredicate, queryable.ElementType);
+
+ }
+ else if (segment is NavigationPropertySegment navigationSegment)
+ {
+ string propertyName = navigationSegment.NavigationProperty.Name;
+
+ if (navigationSegment.NavigationProperty.TargetMultiplicity() == EdmMultiplicity.Many)
+ {
+ queryable = GetCollectionPropertyQuery(queryable, propertyName);
+ }
+ else
+ {
+ queryable = GetSinglePropertyQuery(queryable, propertyName, checkIfNull: true);
+ }
+ }
+ else if (segment is PropertySegment propertySegment)
+ {
+ string propertyName = propertySegment.Property.Name;
+
+ if (propertySegment.Property.Type.IsCollection())
+ {
+ queryable = GetCollectionPropertyQuery(queryable, propertyName);
+ }
+ else
+ {
+ // we don't check whether param.Property is null because
+ // comparisons on complex properties cause errors in EF
+ queryable = GetSinglePropertyQuery(queryable, propertyName, checkIfNull: false);
+ }
+ }
+ else if (segment is CountSegment)
+ {
+ result.HasCountSegment = true;
+ }
+ else if (segment is ValueSegment)
+ {
+ result.HasValueSegment = true;
+ }
+ else
+ {
+ // reached unsupported segment
+ return null;
+ }
+ }
+
+ result.Result = queryable;
+
+ return result;
+ }
+
+ ///
+ /// Transforms by selecting
+ /// the single-valued property of called .
+ ///
+ /// The to apply the property selection to
+ /// The name of the single-valued property to select
+ /// If true, checks whether the property is null before selecting it
+ /// The transformed
+ private static IQueryable GetSinglePropertyQuery(IQueryable queryable, string propertyName, bool checkIfNull = false)
+ {
+ ParameterExpression param = Expression.Parameter(queryable.ElementType);
+ MemberExpression propertyExpression = Expression.Property(param, propertyName);
+ IQueryable result = queryable;
+
+ if (checkIfNull)
+ {
+ // queryable = queryable.Where(entity => entity.Property != null)
+ BinaryExpression condition = Expression.NotEqual(propertyExpression, Expression.Constant(null));
+ LambdaExpression nullFilter = Expression.Lambda(condition, param);
+ result = ExpressionHelpers.Where(queryable, nullFilter, queryable.ElementType);
+ }
+
+ // return queryable.Select(entity => entity.NavProp)
+ LambdaExpression selectBody =
+ Expression.Lambda(propertyExpression, param);
+ return ExpressionHelpers.Select(result, selectBody, queryable.ElementType);
+ }
+
+ ///
+ /// Transforms by selecting
+ /// the collection-valued property called .
+ ///
+ /// The to apply the property selection to
+ /// The name of the collection-valued property to select
+ /// The transformed
+ private static IQueryable GetCollectionPropertyQuery(IQueryable queryable, string propertyName)
+ {
+ ParameterExpression param = Expression.Parameter(queryable.ElementType);
+ MemberExpression propertyExpression = Expression.Property(param, propertyName);
+
+ // for collection properties we use SelectMany instead of Select
+ // because Select would return an IQueryable>,
+ // but SelectMany flattens it to IQueryable
+
+ // we don't check whether the property is null before advancing
+ // because that seems to cause exceptions in EF
+
+ // We expect the collection navigation property to implements IEnumerable
+ // Here we extract the element type T
+ Type collectionPropertyElementType = TypeHelper.GetImplementedIEnumerableType(propertyExpression.Type) ?? propertyExpression.Type;
+
+ // The lambda passed to queryable.SelectMany() has a signature Func>
+ // TSource corresponds to our queryable.ElementType and TResult is the element type of the nav property
+ Type delegateType = typeof(Func<,>).MakeGenericType(
+ queryable.ElementType,
+ typeof(IEnumerable<>).MakeGenericType(collectionPropertyElementType));
+ LambdaExpression selectBody =
+ Expression.Lambda(delegateType, propertyExpression, param);
+
+ // return queryable.SelectMany(entity => entity.CollectionNavProp)
+ return ExpressionHelpers
+ .SelectMany(queryable, selectBody, queryable.ElementType, collectionPropertyElementType);
+ }
+ }
+
+ ///
+ /// Result returned by after
+ /// applying transformations based on path.
+ ///
+ internal class ODataPathQueryResult
+ {
+ ///
+ /// The result of the query transformations applied to the original
+ /// by the
+ ///
+ public IQueryable Result { get; set; }
+ ///
+ /// Whether the path has a $count segment
+ ///
+ public bool HasCountSegment { get; set; }
+ ///
+ /// Whether the path has a $value segment
+ ///
+ public bool HasValueSegment { get; set; }
+ }
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/ODataQueryOptions.cs b/src/Microsoft.AspNet.OData.Shared/Query/ODataQueryOptions.cs
index 13da5b7cfb..29d53cc8e5 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/ODataQueryOptions.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/ODataQueryOptions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/ODataQueryOptionsOfTEntity.cs b/src/Microsoft.AspNet.OData.Shared/Query/ODataQueryOptionsOfTEntity.cs
index 57b2fa5440..4e6a7eb1a4 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/ODataQueryOptionsOfTEntity.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/ODataQueryOptionsOfTEntity.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Linq;
using System.Net.Http.Headers;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/ODataQueryOptionsParserFactory.cs b/src/Microsoft.AspNet.OData.Shared/Query/ODataQueryOptionsParserFactory.cs
index b65c55e20c..3c523d2bef 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/ODataQueryOptionsParserFactory.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/ODataQueryOptionsParserFactory.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/ODataQuerySettings.cs b/src/Microsoft.AspNet.OData.Shared/Query/ODataQuerySettings.cs
index 7dd54179b8..032ba3a097 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/ODataQuerySettings.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/ODataQuerySettings.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/ODataRawQueryOptions.cs b/src/Microsoft.AspNet.OData.Shared/Query/ODataRawQueryOptions.cs
index ac643c3391..1987d07dd2 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/ODataRawQueryOptions.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/ODataRawQueryOptions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
namespace Microsoft.AspNet.OData.Query
{
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/ODataValidationSettings.cs b/src/Microsoft.AspNet.OData.Shared/Query/ODataValidationSettings.cs
index 50b8090e85..f22212c896 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/ODataValidationSettings.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/ODataValidationSettings.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.ObjectModel;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/OrderByAttribute.cs b/src/Microsoft.AspNet.OData.Shared/Query/OrderByAttribute.cs
index ac64441de6..546b6c26ec 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/OrderByAttribute.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/OrderByAttribute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/OrderByCountNode.cs b/src/Microsoft.AspNet.OData.Shared/Query/OrderByCountNode.cs
index b1782f60d5..f906ba9ea7 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/OrderByCountNode.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/OrderByCountNode.cs
@@ -1,5 +1,10 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
+
using Microsoft.AspNet.OData.Common;
using Microsoft.OData.Edm;
using Microsoft.OData.UriParser;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/OrderByItNode.cs b/src/Microsoft.AspNet.OData.Shared/Query/OrderByItNode.cs
index c8b1255227..1cfdedd66e 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/OrderByItNode.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/OrderByItNode.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.OData.UriParser;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/OrderByNode.cs b/src/Microsoft.AspNet.OData.Shared/Query/OrderByNode.cs
index 6b4f72c179..f6bb22ec63 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/OrderByNode.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/OrderByNode.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/OrderByOpenPropertyNode.cs b/src/Microsoft.AspNet.OData.Shared/Query/OrderByOpenPropertyNode.cs
index a8c5c89f9b..c970dfe4bf 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/OrderByOpenPropertyNode.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/OrderByOpenPropertyNode.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Common;
using Microsoft.OData;
@@ -45,4 +49,4 @@ public OrderByOpenPropertyNode(OrderByClause orderByClause)
///
public string PropertyName { get; private set; }
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/OrderByPropertyNode.cs b/src/Microsoft.AspNet.OData.Shared/Query/OrderByPropertyNode.cs
index 9865510bd8..6de79ed469 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/OrderByPropertyNode.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/OrderByPropertyNode.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Common;
using Microsoft.OData;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/OrderByQueryOption.cs b/src/Microsoft.AspNet.OData.Shared/Query/OrderByQueryOption.cs
index e5b8ba1b3c..cbfa57ba30 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/OrderByQueryOption.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/OrderByQueryOption.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/PageAttribute.cs b/src/Microsoft.AspNet.OData.Shared/Query/PageAttribute.cs
index fcda5924ee..834abb4081 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/PageAttribute.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/PageAttribute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/ParameterAliasNodeTranslator.cs b/src/Microsoft.AspNet.OData.Shared/Query/ParameterAliasNodeTranslator.cs
index bce7431a23..d05706d666 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/ParameterAliasNodeTranslator.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/ParameterAliasNodeTranslator.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Linq;
@@ -398,7 +402,7 @@ public override QueryNode Visit(UnaryOperatorNode nodeIn)
/// The translated node.
public override QueryNode Visit(CountNode nodeIn)
{
- return new CountNode((CollectionNode)nodeIn.Source.Accept(this));
+ return new CountNode((CollectionNode)nodeIn.Source.Accept(this), nodeIn.FilterClause, nodeIn.SearchClause);
}
}
}
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/PlainTextODataQueryOptionsParser.cs b/src/Microsoft.AspNet.OData.Shared/Query/PlainTextODataQueryOptionsParser.cs
index 159e3c44fb..07d11bb364 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/PlainTextODataQueryOptionsParser.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/PlainTextODataQueryOptionsParser.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.IO;
using System.Net.Http.Headers;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/QueryOptionSetting.cs b/src/Microsoft.AspNet.OData.Shared/Query/QueryOptionSetting.cs
index bf51fc117e..179f98b4c4 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/QueryOptionSetting.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/QueryOptionSetting.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
namespace Microsoft.AspNet.OData.Query
{
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/SelectAttribute.cs b/src/Microsoft.AspNet.OData.Shared/Query/SelectAttribute.cs
index dbc4f4c3ef..a15fcbcde9 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/SelectAttribute.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/SelectAttribute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/SelectExpandQueryOption.cs b/src/Microsoft.AspNet.OData.Shared/Query/SelectExpandQueryOption.cs
index b380eb8bc3..030883cc2f 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/SelectExpandQueryOption.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/SelectExpandQueryOption.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/SelectExpandType.cs b/src/Microsoft.AspNet.OData.Shared/Query/SelectExpandType.cs
index 845f5e43fe..d3f3c8b611 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/SelectExpandType.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/SelectExpandType.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
namespace Microsoft.AspNet.OData.Query
{
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/SkipQueryOption.cs b/src/Microsoft.AspNet.OData.Shared/Query/SkipQueryOption.cs
index 8372ccf537..1534d6ec6f 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/SkipQueryOption.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/SkipQueryOption.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/SkipTokenHandler.cs b/src/Microsoft.AspNet.OData.Shared/Query/SkipTokenHandler.cs
index cf4254f697..c68f5d1d7f 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/SkipTokenHandler.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/SkipTokenHandler.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Linq;
@@ -38,4 +42,4 @@ public abstract class SkipTokenHandler
/// URI for the NextPageLink.
public abstract Uri GenerateNextPageLink(Uri baseUri, int pageSize, Object instance, ODataSerializerContext context);
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/SkipTokenQueryOption.cs b/src/Microsoft.AspNet.OData.Shared/Query/SkipTokenQueryOption.cs
index cd08e2c96c..ac3898615b 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/SkipTokenQueryOption.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/SkipTokenQueryOption.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
@@ -121,4 +125,4 @@ public void Validate(ODataValidationSettings validationSettings)
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/TopQueryOption.cs b/src/Microsoft.AspNet.OData.Shared/Query/TopQueryOption.cs
index a480dfab37..a91ac9ac21 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/TopQueryOption.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/TopQueryOption.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/TruncatedCollectionOfT.cs b/src/Microsoft.AspNet.OData.Shared/Query/TruncatedCollectionOfT.cs
index c0e1041091..73dbc3c243 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/TruncatedCollectionOfT.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/TruncatedCollectionOfT.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Linq;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/UnsortableAttribute.cs b/src/Microsoft.AspNet.OData.Shared/Query/UnsortableAttribute.cs
index 0e81ed20db..3ab1389fc3 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/UnsortableAttribute.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/UnsortableAttribute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/Validators/CountQueryValidator.cs b/src/Microsoft.AspNet.OData.Shared/Query/Validators/CountQueryValidator.cs
index cf2fd073da..e5ecefcd56 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/Validators/CountQueryValidator.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/Validators/CountQueryValidator.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Common;
@@ -84,4 +88,4 @@ internal static CountQueryValidator GetCountQueryValidator(ODataQueryContext con
: context.RequestContainer.GetRequiredService();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/Validators/FilterQueryValidator.cs b/src/Microsoft.AspNet.OData.Shared/Query/Validators/FilterQueryValidator.cs
index d71725614e..2732f897fa 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/Validators/FilterQueryValidator.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/Validators/FilterQueryValidator.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts;
@@ -332,6 +336,36 @@ public virtual void ValidateConvertNode(ConvertNode convertNode, ODataValidation
ValidateQueryNode(convertNode.Source, settings);
}
+ ///
+ /// Override this method to restrict the '$count' inside the filter query.
+ ///
+ ///
+ ///
+ public virtual void ValidateCountNode(CountNode countNode, ODataValidationSettings settings)
+ {
+ if (countNode == null)
+ {
+ throw Error.ArgumentNull("countNode");
+ }
+
+ if (settings == null)
+ {
+ throw Error.ArgumentNull("settings");
+ }
+
+ ValidateQueryNode(countNode.Source, settings);
+
+ if (countNode.FilterClause != null)
+ {
+ ValidateQueryNode(countNode.FilterClause.Expression, settings);
+ }
+
+ if (countNode.SearchClause != null)
+ {
+ ValidateQueryNode(countNode.SearchClause.Expression, settings);
+ }
+ }
+
///
/// Override this method for the navigation property node.
///
@@ -782,6 +816,10 @@ private void ValidateSingleValueNode(SingleValueNode node, ODataValidationSettin
ValidateConvertNode(node as ConvertNode, settings);
break;
+ case QueryNodeKind.Count:
+ ValidateCountNode(node as CountNode, settings);
+ break;
+
case QueryNodeKind.ResourceRangeVariableReference:
ValidateRangeVariable((node as ResourceRangeVariableReferenceNode).RangeVariable, settings);
break;
@@ -1036,4 +1074,4 @@ private static AllowedArithmeticOperators ToArithmeticOperator(BinaryOperatorNod
return result;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/Validators/ODataQueryValidator.cs b/src/Microsoft.AspNet.OData.Shared/Query/Validators/ODataQueryValidator.cs
index ce907a7388..61d4298146 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/Validators/ODataQueryValidator.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/Validators/ODataQueryValidator.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Common;
using Microsoft.Extensions.DependencyInjection;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/Validators/OrderByModelLimitationsValidator.cs b/src/Microsoft.AspNet.OData.Shared/Query/Validators/OrderByModelLimitationsValidator.cs
index ac05bb5488..5a50b27911 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/Validators/OrderByModelLimitationsValidator.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/Validators/OrderByModelLimitationsValidator.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Common;
using Microsoft.AspNet.OData.Formatter;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/Validators/OrderByQueryValidator.cs b/src/Microsoft.AspNet.OData.Shared/Query/Validators/OrderByQueryValidator.cs
index d26aca9e48..a554cc92b7 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/Validators/OrderByQueryValidator.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/Validators/OrderByQueryValidator.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Common;
using Microsoft.Extensions.DependencyInjection;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/Validators/SelectExpandQueryValidator.cs b/src/Microsoft.AspNet.OData.Shared/Query/Validators/SelectExpandQueryValidator.cs
index 278998e4ae..a0d620955e 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/Validators/SelectExpandQueryValidator.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/Validators/SelectExpandQueryValidator.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/Validators/SkipQueryValidator.cs b/src/Microsoft.AspNet.OData.Shared/Query/Validators/SkipQueryValidator.cs
index 6a2c114698..7c213ade7e 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/Validators/SkipQueryValidator.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/Validators/SkipQueryValidator.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Common;
using Microsoft.Extensions.DependencyInjection;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/Validators/SkipTokenQueryValidator.cs b/src/Microsoft.AspNet.OData.Shared/Query/Validators/SkipTokenQueryValidator.cs
index be8d3db97d..fba21f52f5 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/Validators/SkipTokenQueryValidator.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/Validators/SkipTokenQueryValidator.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Common;
using Microsoft.Extensions.DependencyInjection;
diff --git a/src/Microsoft.AspNet.OData.Shared/Query/Validators/TopQueryValidator.cs b/src/Microsoft.AspNet.OData.Shared/Query/Validators/TopQueryValidator.cs
index c5c0c64417..2d31fb1ebc 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/Validators/TopQueryValidator.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/Validators/TopQueryValidator.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Common;
using Microsoft.AspNet.OData.Formatter;
diff --git a/src/Microsoft.AspNet.OData.Shared/QueryHelpers.cs b/src/Microsoft.AspNet.OData.Shared/QueryHelpers.cs
new file mode 100644
index 0000000000..b8c5ed724a
--- /dev/null
+++ b/src/Microsoft.AspNet.OData.Shared/QueryHelpers.cs
@@ -0,0 +1,54 @@
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
+
+using System;
+using System.Linq;
+using Microsoft.AspNet.OData.Common;
+using Microsoft.AspNet.OData.Interfaces;
+
+namespace Microsoft.AspNet.OData.Query
+{
+ internal static class QueryHelpers
+ {
+ ///
+ /// Get a single or default value from a collection.
+ ///
+ /// The response value as .
+ /// The action context, i.e. action and controller name.
+ ///
+ internal static object SingleOrDefault(
+ IQueryable queryable,
+ IWebApiActionDescriptor actionDescriptor)
+ {
+ var enumerator = queryable.GetEnumerator();
+ try
+ {
+ var result = enumerator.MoveNext() ? enumerator.Current : null;
+
+ if (enumerator.MoveNext())
+ {
+ throw new InvalidOperationException(Error.Format(
+ SRResources.SingleResultHasMoreThanOneEntity,
+ actionDescriptor.ActionName,
+ actionDescriptor.ControllerName,
+ "SingleResult"));
+ }
+
+ return result;
+ }
+ finally
+ {
+ // Ensure any active/open database objects that were created
+ // iterating over the IQueryable object are properly closed.
+ if (enumerator is IDisposable disposable)
+ {
+ disposable.Dispose();
+ }
+ }
+ }
+ }
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/QueryableRestrictions.cs b/src/Microsoft.AspNet.OData.Shared/QueryableRestrictions.cs
index e35171d2b1..1fd04092ee 100644
--- a/src/Microsoft.AspNet.OData.Shared/QueryableRestrictions.cs
+++ b/src/Microsoft.AspNet.OData.Shared/QueryableRestrictions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Builder;
diff --git a/src/Microsoft.AspNet.OData.Shared/QueryableRestrictionsAnnotation.cs b/src/Microsoft.AspNet.OData.Shared/QueryableRestrictionsAnnotation.cs
index 42a0d4b9e0..392c486ffe 100644
--- a/src/Microsoft.AspNet.OData.Shared/QueryableRestrictionsAnnotation.cs
+++ b/src/Microsoft.AspNet.OData.Shared/QueryableRestrictionsAnnotation.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/RequestMethod.cs b/src/Microsoft.AspNet.OData.Shared/RequestMethod.cs
index fc338be489..ddf9afcfa6 100644
--- a/src/Microsoft.AspNet.OData.Shared/RequestMethod.cs
+++ b/src/Microsoft.AspNet.OData.Shared/RequestMethod.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
namespace Microsoft.AspNet.OData
{
diff --git a/src/Microsoft.AspNet.OData.Shared/RequestPreferenceHelpers.cs b/src/Microsoft.AspNet.OData.Shared/RequestPreferenceHelpers.cs
index f3186fd24b..144ac4d620 100644
--- a/src/Microsoft.AspNet.OData.Shared/RequestPreferenceHelpers.cs
+++ b/src/Microsoft.AspNet.OData.Shared/RequestPreferenceHelpers.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/ResourceContext.cs b/src/Microsoft.AspNet.OData.Shared/ResourceContext.cs
index bf587f6ab2..529c8287e0 100644
--- a/src/Microsoft.AspNet.OData.Shared/ResourceContext.cs
+++ b/src/Microsoft.AspNet.OData.Shared/ResourceContext.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
@@ -191,12 +195,21 @@ public object GetPropertyValue(string propertyName)
}
object value;
+ if (SerializerContext.IsDeltaOfT)
+ {
+ IDelta delta = ResourceInstance as IDelta;
+ if (delta != null && delta.TryGetPropertyValue(propertyName, out value))
+ {
+ return value;
+ }
+ }
+
if (EdmObject.TryGetPropertyValue(propertyName, out value))
{
return value;
}
else
- {
+ {
IEdmTypeReference edmType = EdmObject.GetEdmType();
if (edmType == null)
{
diff --git a/src/Microsoft.AspNet.OData.Shared/ResourceContextOfTStructuredType.cs b/src/Microsoft.AspNet.OData.Shared/ResourceContextOfTStructuredType.cs
index 6f80d02906..82a3d8d41c 100644
--- a/src/Microsoft.AspNet.OData.Shared/ResourceContextOfTStructuredType.cs
+++ b/src/Microsoft.AspNet.OData.Shared/ResourceContextOfTStructuredType.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
diff --git a/src/Microsoft.AspNet.OData.Shared/ResourceSetContext.cs b/src/Microsoft.AspNet.OData.Shared/ResourceSetContext.cs
index 4da796164f..e2c0e4f9d8 100644
--- a/src/Microsoft.AspNet.OData.Shared/ResourceSetContext.cs
+++ b/src/Microsoft.AspNet.OData.Shared/ResourceSetContext.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Interfaces;
using Microsoft.OData.Edm;
diff --git a/src/Microsoft.AspNet.OData.Shared/Results/ResultHelpers.cs b/src/Microsoft.AspNet.OData.Shared/Results/ResultHelpers.cs
index 7c3db3aa73..53687fc3ab 100644
--- a/src/Microsoft.AspNet.OData.Shared/Results/ResultHelpers.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Results/ResultHelpers.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/ActionMapExtensions.cs b/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/ActionMapExtensions.cs
index 4cbea4104e..2fcb2d9d5c 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/ActionMapExtensions.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/ActionMapExtensions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Interfaces;
@@ -23,4 +27,4 @@ public static string FindMatchingAction(this IWebApiActionMap actionMap, params
return null;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/ActionRoutingConvention.cs b/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/ActionRoutingConvention.cs
index 784371d938..c4902c78bf 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/ActionRoutingConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/ActionRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Linq;
using Microsoft.AspNet.OData.Interfaces;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/AttributeRoutingConvention.cs b/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/AttributeRoutingConvention.cs
index e65409cf70..4aacdd9718 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/AttributeRoutingConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/AttributeRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/DynamicPropertyRoutingConvention.cs b/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/DynamicPropertyRoutingConvention.cs
index bd933d7d30..a8f76ce259 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/DynamicPropertyRoutingConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/DynamicPropertyRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Diagnostics.CodeAnalysis;
@@ -96,4 +100,4 @@ internal static string SelectActionImpl(ODataPath odataPath, IWebApiControllerCo
return null;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/EntityRoutingConvention.cs b/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/EntityRoutingConvention.cs
index 58e8d4cda1..13014736cd 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/EntityRoutingConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/EntityRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Diagnostics.Contracts;
using System.Linq;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/EntitySetRoutingConvention.cs b/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/EntitySetRoutingConvention.cs
index c287c506c5..38b775a6a4 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/EntitySetRoutingConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/EntitySetRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Interfaces;
using Microsoft.OData.Edm;
@@ -42,6 +46,13 @@ internal static string SelectActionImpl(ODataPath odataPath, IWebApiControllerCo
"Post" + entitySet.EntityType().Name,
"Post");
}
+ else if (ODataRequestMethod.Patch == controllerContext.Request.Method)
+ {
+ // e.g. Try PatchCustomers first, then fall back to Patch action name
+ return actionMap.FindMatchingAction(
+ "Patch" + entitySet.Name,
+ "Patch");
+ }
}
else if (odataPath.PathTemplate == "~/entityset/$count" &&
ODataRequestMethod.Get == controllerContext.Request.GetRequestMethodOrPreflightMethod())
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/FunctionRoutingConvention.cs b/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/FunctionRoutingConvention.cs
index a32c3305c1..90d7c4192b 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/FunctionRoutingConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/FunctionRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Diagnostics.CodeAnalysis;
using System.Linq;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/MetadataRoutingConvention.cs b/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/MetadataRoutingConvention.cs
index 818e5448cb..5319c237fc 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/MetadataRoutingConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/MetadataRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Common;
using Microsoft.AspNet.OData.Interfaces;
@@ -79,4 +83,4 @@ internal static string SelectActionImpl(ODataPath odataPath, IWebApiControllerCo
return null;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/NavigationRoutingConvention.cs b/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/NavigationRoutingConvention.cs
index 6b984ec86c..591714dd27 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/NavigationRoutingConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/NavigationRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Linq;
@@ -46,9 +50,9 @@ internal static string SelectActionImpl(ODataPath odataPath, IWebApiControllerCo
return null;
}
- // It is not valid to *Put/Patch" to any collection-valued navigation property.
+ // It is not valid to *Put" to any collection-valued navigation property.
if (navigationProperty.TargetMultiplicity() == EdmMultiplicity.Many &&
- (ODataRequestMethod.Put == method || ODataRequestMethod.Patch == method))
+ ODataRequestMethod.Put == method)
{
return null;
}
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/NavigationSourceRoutingConvention.cs b/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/NavigationSourceRoutingConvention.cs
index b853b96a1a..b485aca893 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/NavigationSourceRoutingConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/NavigationSourceRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Linq;
using Microsoft.OData.UriParser;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/NestedPathsRoutingConvention.cs b/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/NestedPathsRoutingConvention.cs
new file mode 100644
index 0000000000..a582983078
--- /dev/null
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/NestedPathsRoutingConvention.cs
@@ -0,0 +1,93 @@
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
+
+#if NETCORE
+
+// TODO: [EnableNestedPaths] feature has not yet been ported to AspNet classic
+
+using System.Linq;
+using Microsoft.AspNet.OData.Interfaces;
+using Microsoft.OData.UriParser;
+
+namespace Microsoft.AspNet.OData.Routing.Conventions
+{
+ ///
+ /// An implementation of that handles GET requests
+ /// to arbitrarily nested paths. It requires a controller action with the [EnableNestedPaths] attribute.
+ /// This should be the last convention in order not to override other routing conventions that
+ /// rely on user-defined methods.
+ ///
+ public partial class NestedPathsRoutingConvention : NavigationSourceRoutingConvention
+ {
+ ///
+ /// Selects the action for OData requests.
+ ///
+ /// The OData path.
+ /// The controller context.
+ /// The action map.
+ ///
+ /// null if the request isn't handled by this convention; otherwise, the name of the selected action
+ ///
+ internal static string SelectActionImpl(ODataPath odataPath, IWebApiControllerContext controllerContext, IWebApiActionMap actionMap)
+ {
+
+ ODataRequestMethod method = controllerContext.Request.GetRequestMethodOrPreflightMethod();
+
+ if (method != ODataRequestMethod.Get)
+ {
+ // [EnableNestedPaths] only supports GET requests
+ return null;
+ }
+
+ // unsupported path segments
+ if (odataPath.PathTemplate.EndsWith("$ref"))
+ {
+ return null;
+ }
+
+ ODataPathSegment firstSegment = odataPath.Segments.FirstOrDefault();
+
+ string sourceName;
+ if (firstSegment is EntitySetSegment entitySetSegment)
+ {
+ sourceName = entitySetSegment.EntitySet.Name;
+ }
+ else if (firstSegment is SingletonSegment singletonSegment)
+ {
+ sourceName = singletonSegment.Singleton.Name;
+ }
+ else
+ {
+ // this only supports paths starting with an entity set or singleton
+ return null;
+ }
+
+ // if we did not find a matching action amongst the conventional user-defined methods
+ // then let's check if the controller has a Get method with [EnableNestedPaths] attribute
+ // which should be used to catch any nested GET request
+ string action = actionMap.FindMatchingAction("Get" + sourceName, "Get");
+ if (action == null)
+ {
+ return null;
+ }
+
+ IWebApiActionDescriptor descriptor = actionMap.GetActionDescriptor(action);
+ if (descriptor == null)
+ {
+ return null;
+ }
+
+ if (!descriptor.GetCustomAttributes(/* inherit */ true).Any())
+ {
+ return null;
+ }
+
+ return descriptor.ActionName;
+ }
+ }
+}
+#endif
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/OperationImportRoutingConvention.cs b/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/OperationImportRoutingConvention.cs
index c20313b02d..5582082dce 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/OperationImportRoutingConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/OperationImportRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Linq;
using Microsoft.AspNet.OData.Interfaces;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/PropertyRoutingConvention.cs b/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/PropertyRoutingConvention.cs
index f8d5bc25cd..04ab44d36e 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/PropertyRoutingConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/PropertyRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Diagnostics.CodeAnalysis;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/RefRoutingConvention.cs b/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/RefRoutingConvention.cs
index 171b030eb4..e0ad45adb9 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/RefRoutingConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/RefRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Linq;
@@ -112,4 +116,4 @@ private static bool IsSupportedRequestMethod(ODataRequestMethod method)
ODataRequestMethod.Get == method);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/RequestMethodExtensions.cs b/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/RequestMethodExtensions.cs
index 7791bcd0d0..fcda951443 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/RequestMethodExtensions.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/RequestMethodExtensions.cs
@@ -1,4 +1,11 @@
-using System;
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
+
+using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNet.OData.Interfaces;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/RoutingConventionHelpers.cs b/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/RoutingConventionHelpers.cs
index 0fedebbc22..2c5fd5ffa4 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/RoutingConventionHelpers.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/RoutingConventionHelpers.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/SelectControllerResult.cs b/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/SelectControllerResult.cs
index 090972440a..4a771fbf1c 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/SelectControllerResult.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/SelectControllerResult.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/SingletonRoutingConvention.cs b/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/SingletonRoutingConvention.cs
index f77a48ddef..40c4b556c2 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/SingletonRoutingConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/SingletonRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Interfaces;
using Microsoft.OData.Edm;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/UnmappedRequestRoutingConvention.cs b/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/UnmappedRequestRoutingConvention.cs
index f4b6448950..967f267510 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/UnmappedRequestRoutingConvention.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/Conventions/UnmappedRequestRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Interfaces;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/DefaultODataPathHandler.cs b/src/Microsoft.AspNet.OData.Shared/Routing/DefaultODataPathHandler.cs
index a9d8393192..bcad356567 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/DefaultODataPathHandler.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/DefaultODataPathHandler.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/DefaultODataPathValidator.cs b/src/Microsoft.AspNet.OData.Shared/Routing/DefaultODataPathValidator.cs
index 3b82f798d9..0a4ab53675 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/DefaultODataPathValidator.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/DefaultODataPathValidator.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Common;
using Microsoft.AspNet.OData.Formatter;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/IODataPathHandler.cs b/src/Microsoft.AspNet.OData.Shared/Routing/IODataPathHandler.cs
index 7eaaa46b2a..e658542b74 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/IODataPathHandler.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/IODataPathHandler.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Diagnostics.CodeAnalysis;
@@ -35,4 +39,4 @@ public interface IODataPathHandler
///
ODataUrlKeyDelimiter UrlKeyDelimiter { get; set; }
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/IODataPathTemplateHandler.cs b/src/Microsoft.AspNet.OData.Shared/Routing/IODataPathTemplateHandler.cs
index 947070edaf..bee4938d7f 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/IODataPathTemplateHandler.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/IODataPathTemplateHandler.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Diagnostics.CodeAnalysis;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/KeyValueParser.cs b/src/Microsoft.AspNet.OData.Shared/Routing/KeyValueParser.cs
index 06dac87269..e7635fe52f 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/KeyValueParser.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/KeyValueParser.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/ODataOptionalParameter.cs b/src/Microsoft.AspNet.OData.Shared/Routing/ODataOptionalParameter.cs
index 82431b2fc0..b54d80bec0 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/ODataOptionalParameter.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/ODataOptionalParameter.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using Microsoft.OData.Edm;
@@ -23,4 +27,4 @@ public void Add(IEdmOptionalParameter parameter)
_optionalParameters.Add(parameter);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/ODataParameterHelper.cs b/src/Microsoft.AspNet.OData.Shared/Routing/ODataParameterHelper.cs
index 0d3d6660f6..eebd2aac78 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/ODataParameterHelper.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/ODataParameterHelper.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Diagnostics.CodeAnalysis;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/ODataParameterValue.cs b/src/Microsoft.AspNet.OData.Shared/Routing/ODataParameterValue.cs
index 19e0f5b14d..f06bf36be9 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/ODataParameterValue.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/ODataParameterValue.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Common;
using Microsoft.OData.Edm;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/ODataPath.cs b/src/Microsoft.AspNet.OData.Shared/Routing/ODataPath.cs
index 0acf3a8c06..7a7eb799a1 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/ODataPath.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/ODataPath.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Collections.ObjectModel;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/ODataPathParameterBindingAttribute.cs b/src/Microsoft.AspNet.OData.Shared/Routing/ODataPathParameterBindingAttribute.cs
index 5be9be4caa..55593fcfa0 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/ODataPathParameterBindingAttribute.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/ODataPathParameterBindingAttribute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
namespace Microsoft.AspNet.OData.Routing
{
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/ODataPathRouteConstraint.cs b/src/Microsoft.AspNet.OData.Shared/Routing/ODataPathRouteConstraint.cs
index 2e9f11a6cf..fcd8577be8 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/ODataPathRouteConstraint.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/ODataPathRouteConstraint.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/ODataPathSegmentExtensions.cs b/src/Microsoft.AspNet.OData.Shared/Routing/ODataPathSegmentExtensions.cs
index d9a5b64480..1ae4b8465f 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/ODataPathSegmentExtensions.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/ODataPathSegmentExtensions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/ODataPathSegmentHandler.cs b/src/Microsoft.AspNet.OData.Shared/Routing/ODataPathSegmentHandler.cs
index 89f440eb48..d270e9d660 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/ODataPathSegmentHandler.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/ODataPathSegmentHandler.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/ODataPathSegmentTranslator.cs b/src/Microsoft.AspNet.OData.Shared/Routing/ODataPathSegmentTranslator.cs
index 0637e63553..7c9834f8c2 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/ODataPathSegmentTranslator.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/ODataPathSegmentTranslator.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Diagnostics.Contracts;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/ODataRoute.cs b/src/Microsoft.AspNet.OData.Shared/Routing/ODataRoute.cs
index c10a9d5101..5c6258b31b 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/ODataRoute.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/ODataRoute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Diagnostics.Contracts;
@@ -71,4 +75,4 @@ private static string UriEncode(string str)
return escape;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/ODataRouteAttribute.cs b/src/Microsoft.AspNet.OData.Shared/Routing/ODataRouteAttribute.cs
index f68f1694a8..58a177d558 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/ODataRouteAttribute.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/ODataRouteAttribute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/ODataRouteConstants.cs b/src/Microsoft.AspNet.OData.Shared/Routing/ODataRouteConstants.cs
index ef63fe81e7..0e05573f0f 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/ODataRouteConstants.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/ODataRouteConstants.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
namespace Microsoft.AspNet.OData.Routing
{
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/ODataRoutePrefixAttribute.cs b/src/Microsoft.AspNet.OData.Shared/Routing/ODataRoutePrefixAttribute.cs
index 54fd9bd3ad..28f847d237 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/ODataRoutePrefixAttribute.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/ODataRoutePrefixAttribute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/ODataSegmentKinds.cs b/src/Microsoft.AspNet.OData.Shared/Routing/ODataSegmentKinds.cs
index 215505b7dc..a3acb36b56 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/ODataSegmentKinds.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/ODataSegmentKinds.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
namespace Microsoft.AspNet.OData.Routing
{
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/ODataVersionConstraint.cs b/src/Microsoft.AspNet.OData.Shared/Routing/ODataVersionConstraint.cs
index ca9a36ddc3..6541dceb1d 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/ODataVersionConstraint.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/ODataVersionConstraint.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Linq;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/Template/DynamicSegmentTemplate.cs b/src/Microsoft.AspNet.OData.Shared/Routing/Template/DynamicSegmentTemplate.cs
index 87ceb198c0..da03080a4a 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/Template/DynamicSegmentTemplate.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/Template/DynamicSegmentTemplate.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/Template/EntitySetSegmentTemplate.cs b/src/Microsoft.AspNet.OData.Shared/Routing/Template/EntitySetSegmentTemplate.cs
index 2ac3afbacd..345bfe6138 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/Template/EntitySetSegmentTemplate.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/Template/EntitySetSegmentTemplate.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/Template/KeySegmentTemplate.cs b/src/Microsoft.AspNet.OData.Shared/Routing/Template/KeySegmentTemplate.cs
index 525ab9118f..1877f4bb0d 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/Template/KeySegmentTemplate.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/Template/KeySegmentTemplate.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/Template/NavigationPropertyLinkSegmentTemplate.cs b/src/Microsoft.AspNet.OData.Shared/Routing/Template/NavigationPropertyLinkSegmentTemplate.cs
index d98f2a1001..3ae8f8e21e 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/Template/NavigationPropertyLinkSegmentTemplate.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/Template/NavigationPropertyLinkSegmentTemplate.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/Template/NavigationPropertySegmentTemplate.cs b/src/Microsoft.AspNet.OData.Shared/Routing/Template/NavigationPropertySegmentTemplate.cs
index 70cb2ad92f..66f9492911 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/Template/NavigationPropertySegmentTemplate.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/Template/NavigationPropertySegmentTemplate.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/Template/ODataPathSegmentTemplate.cs b/src/Microsoft.AspNet.OData.Shared/Routing/Template/ODataPathSegmentTemplate.cs
index 2abd4ba00b..eedaab4bb6 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/Template/ODataPathSegmentTemplate.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/Template/ODataPathSegmentTemplate.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using Microsoft.OData.UriParser;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/Template/ODataPathSegmentTemplateOfT.cs b/src/Microsoft.AspNet.OData.Shared/Routing/Template/ODataPathSegmentTemplateOfT.cs
index 06c13caa02..0f1311e331 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/Template/ODataPathSegmentTemplateOfT.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/Template/ODataPathSegmentTemplateOfT.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using Microsoft.OData.UriParser;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/Template/ODataPathSegmentTemplateTranslator.cs b/src/Microsoft.AspNet.OData.Shared/Routing/Template/ODataPathSegmentTemplateTranslator.cs
index 38d0bb8b57..357d6ddcdf 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/Template/ODataPathSegmentTemplateTranslator.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/Template/ODataPathSegmentTemplateTranslator.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Common;
using Microsoft.OData;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/Template/ODataPathTemplate.cs b/src/Microsoft.AspNet.OData.Shared/Routing/Template/ODataPathTemplate.cs
index 50452bde3d..2826af3cec 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/Template/ODataPathTemplate.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/Template/ODataPathTemplate.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Collections.ObjectModel;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/Template/OperationImportSegmentTemplate.cs b/src/Microsoft.AspNet.OData.Shared/Routing/Template/OperationImportSegmentTemplate.cs
index 94deb63d54..4e9c493842 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/Template/OperationImportSegmentTemplate.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/Template/OperationImportSegmentTemplate.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Linq;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/Template/OperationSegmentTemplate.cs b/src/Microsoft.AspNet.OData.Shared/Routing/Template/OperationSegmentTemplate.cs
index d2d30cdb35..c95a4bb93e 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/Template/OperationSegmentTemplate.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/Template/OperationSegmentTemplate.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Linq;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/Template/PathTemplateSegmentTemplate.cs b/src/Microsoft.AspNet.OData.Shared/Routing/Template/PathTemplateSegmentTemplate.cs
index 95817a7df1..ff143cbb81 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/Template/PathTemplateSegmentTemplate.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/Template/PathTemplateSegmentTemplate.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/Template/PropertySegmentTemplate.cs b/src/Microsoft.AspNet.OData.Shared/Routing/Template/PropertySegmentTemplate.cs
index ab38d6a3dd..02bcbd2b64 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/Template/PropertySegmentTemplate.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/Template/PropertySegmentTemplate.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/Template/SingletonSegmentTemplate.cs b/src/Microsoft.AspNet.OData.Shared/Routing/Template/SingletonSegmentTemplate.cs
index f23f5dd5f8..208d94418d 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/Template/SingletonSegmentTemplate.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/Template/SingletonSegmentTemplate.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/Template/TypeSegmentTemplate.cs b/src/Microsoft.AspNet.OData.Shared/Routing/Template/TypeSegmentTemplate.cs
index 85ce336de5..db1b5bda4c 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/Template/TypeSegmentTemplate.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/Template/TypeSegmentTemplate.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData.Shared/Routing/UnresolvedPathSegment.cs b/src/Microsoft.AspNet.OData.Shared/Routing/UnresolvedPathSegment.cs
index e9e2e49c12..25f23a8715 100644
--- a/src/Microsoft.AspNet.OData.Shared/Routing/UnresolvedPathSegment.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Routing/UnresolvedPathSegment.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Common;
using Microsoft.OData.Edm;
diff --git a/src/Microsoft.AspNet.OData.Shared/TimeZoneInfoHelper.cs b/src/Microsoft.AspNet.OData.Shared/TimeZoneInfoHelper.cs
index 1c6e38925e..860896e644 100644
--- a/src/Microsoft.AspNet.OData.Shared/TimeZoneInfoHelper.cs
+++ b/src/Microsoft.AspNet.OData.Shared/TimeZoneInfoHelper.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
diff --git a/src/Microsoft.AspNet.OData.Shared/TransientAnnotations.cs b/src/Microsoft.AspNet.OData.Shared/TransientAnnotations.cs
new file mode 100644
index 0000000000..1946f2f18b
--- /dev/null
+++ b/src/Microsoft.AspNet.OData.Shared/TransientAnnotations.cs
@@ -0,0 +1,13 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+
+using System.Collections.Generic;
+using Microsoft.AspNet.OData.Common;
+
+namespace Microsoft.AspNet.OData
+{
+ internal static class TransientAnnotations
+ {
+ internal static HashSet TransientAnnotationTerms = new HashSet() { SRResources.ContentID, SRResources.DataModificationException };
+ }
+}
diff --git a/src/Microsoft.AspNet.OData.Shared/TypeHelper.cs b/src/Microsoft.AspNet.OData.Shared/TypeHelper.cs
index 54ef2adfb7..39aeb90981 100644
--- a/src/Microsoft.AspNet.OData.Shared/TypeHelper.cs
+++ b/src/Microsoft.AspNet.OData.Shared/TypeHelper.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/TypedDelta.cs b/src/Microsoft.AspNet.OData.Shared/TypedDelta.cs
index c0704162ac..ad88b237bb 100644
--- a/src/Microsoft.AspNet.OData.Shared/TypedDelta.cs
+++ b/src/Microsoft.AspNet.OData.Shared/TypedDelta.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
@@ -28,7 +32,7 @@ public abstract class TypedDelta : Delta
/// True if it is a Delta generic type; false otherwise.
internal static bool IsDeltaOfT(Type type)
{
- return type != null && TypeHelper.IsGenericType(type) && type.GetGenericTypeDefinition() == typeof(Delta<>);
+ return type != null && TypeHelper.IsGenericType(type) && typeof(Delta<>).IsAssignableFrom(type.GetGenericTypeDefinition());
}
}
}
diff --git a/src/Microsoft.AspNet.OData.Shared/UnqualifiedCallAndEnumPrefixFreeResolver.cs b/src/Microsoft.AspNet.OData.Shared/UnqualifiedCallAndEnumPrefixFreeResolver.cs
index bb2083b5c4..ed9ae2eef6 100644
--- a/src/Microsoft.AspNet.OData.Shared/UnqualifiedCallAndEnumPrefixFreeResolver.cs
+++ b/src/Microsoft.AspNet.OData.Shared/UnqualifiedCallAndEnumPrefixFreeResolver.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData.Shared/WebApiAssembliesResolver.cs b/src/Microsoft.AspNet.OData.Shared/WebApiAssembliesResolver.cs
index 96de373233..b5fdf85d8d 100644
--- a/src/Microsoft.AspNet.OData.Shared/WebApiAssembliesResolver.cs
+++ b/src/Microsoft.AspNet.OData.Shared/WebApiAssembliesResolver.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Interfaces;
diff --git a/src/Microsoft.AspNet.OData/Adapters/WebApiActionDescriptor.cs b/src/Microsoft.AspNet.OData/Adapters/WebApiActionDescriptor.cs
index b87c7e0d74..6cb29f7cd1 100644
--- a/src/Microsoft.AspNet.OData/Adapters/WebApiActionDescriptor.cs
+++ b/src/Microsoft.AspNet.OData/Adapters/WebApiActionDescriptor.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData/Adapters/WebApiActionMap.cs b/src/Microsoft.AspNet.OData/Adapters/WebApiActionMap.cs
index ae0cda1618..33717781ea 100644
--- a/src/Microsoft.AspNet.OData/Adapters/WebApiActionMap.cs
+++ b/src/Microsoft.AspNet.OData/Adapters/WebApiActionMap.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Linq;
using System.Web.Http.Controllers;
@@ -41,5 +45,17 @@ public bool Contains(string name)
{
return this.innerMap.Contains(name);
}
+
+ ///
+ /// Gets the action descriptor of the specified action
+ ///
+ /// The name of the action
+ /// The if it exists, otherwise null
+ public IWebApiActionDescriptor GetActionDescriptor(string actionName)
+ {
+ IGrouping group = this.innerMap.FirstOrDefault(g => g.Key == actionName);
+ HttpActionDescriptor descriptor = group?.FirstOrDefault();
+ return descriptor == null ? null : new WebApiActionDescriptor(descriptor);
+ }
}
}
diff --git a/src/Microsoft.AspNet.OData/Adapters/WebApiAssembliesResolver.cs b/src/Microsoft.AspNet.OData/Adapters/WebApiAssembliesResolver.cs
index 0e1195f470..3ef38cf3ec 100644
--- a/src/Microsoft.AspNet.OData/Adapters/WebApiAssembliesResolver.cs
+++ b/src/Microsoft.AspNet.OData/Adapters/WebApiAssembliesResolver.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Reflection;
diff --git a/src/Microsoft.AspNet.OData/Adapters/WebApiContext.cs b/src/Microsoft.AspNet.OData/Adapters/WebApiContext.cs
index 16c84d23c5..c77bd2dec8 100644
--- a/src/Microsoft.AspNet.OData/Adapters/WebApiContext.cs
+++ b/src/Microsoft.AspNet.OData/Adapters/WebApiContext.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData/Adapters/WebApiControllerContext.cs b/src/Microsoft.AspNet.OData/Adapters/WebApiControllerContext.cs
index 624fd44610..63870a699d 100644
--- a/src/Microsoft.AspNet.OData/Adapters/WebApiControllerContext.cs
+++ b/src/Microsoft.AspNet.OData/Adapters/WebApiControllerContext.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Net.Http;
diff --git a/src/Microsoft.AspNet.OData/Adapters/WebApiOptions.cs b/src/Microsoft.AspNet.OData/Adapters/WebApiOptions.cs
index 8158c94407..b737f206a9 100644
--- a/src/Microsoft.AspNet.OData/Adapters/WebApiOptions.cs
+++ b/src/Microsoft.AspNet.OData/Adapters/WebApiOptions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Web.Http;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData/Adapters/WebApiRequestHeaders.cs b/src/Microsoft.AspNet.OData/Adapters/WebApiRequestHeaders.cs
index be6739858c..492f0eb4b3 100644
--- a/src/Microsoft.AspNet.OData/Adapters/WebApiRequestHeaders.cs
+++ b/src/Microsoft.AspNet.OData/Adapters/WebApiRequestHeaders.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Net.Http.Headers;
diff --git a/src/Microsoft.AspNet.OData/Adapters/WebApiRequestMessage.cs b/src/Microsoft.AspNet.OData/Adapters/WebApiRequestMessage.cs
index e075bdb79a..86b2d3756c 100644
--- a/src/Microsoft.AspNet.OData/Adapters/WebApiRequestMessage.cs
+++ b/src/Microsoft.AspNet.OData/Adapters/WebApiRequestMessage.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData/Adapters/WebApiUrlHelper.cs b/src/Microsoft.AspNet.OData/Adapters/WebApiUrlHelper.cs
index 0b0c67ef4a..877de940c6 100644
--- a/src/Microsoft.AspNet.OData/Adapters/WebApiUrlHelper.cs
+++ b/src/Microsoft.AspNet.OData/Adapters/WebApiUrlHelper.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Web.Http.Routing;
diff --git a/src/Microsoft.AspNet.OData/Batch/ChangeSetRequestItem.cs b/src/Microsoft.AspNet.OData/Batch/ChangeSetRequestItem.cs
index 4c8a3772e3..516eb0fd74 100644
--- a/src/Microsoft.AspNet.OData/Batch/ChangeSetRequestItem.cs
+++ b/src/Microsoft.AspNet.OData/Batch/ChangeSetRequestItem.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
@@ -120,4 +124,4 @@ internal static void DisposeResponses(List responses)
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData/Batch/ChangeSetResponseItem.cs b/src/Microsoft.AspNet.OData/Batch/ChangeSetResponseItem.cs
index f0913151f7..1c371be917 100644
--- a/src/Microsoft.AspNet.OData/Batch/ChangeSetResponseItem.cs
+++ b/src/Microsoft.AspNet.OData/Batch/ChangeSetResponseItem.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Linq;
@@ -94,4 +98,4 @@ protected override void Dispose(bool disposing)
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData/Batch/DefaultODataBatchHandler.cs b/src/Microsoft.AspNet.OData/Batch/DefaultODataBatchHandler.cs
index 6c83bd05bd..c353b74df0 100644
--- a/src/Microsoft.AspNet.OData/Batch/DefaultODataBatchHandler.cs
+++ b/src/Microsoft.AspNet.OData/Batch/DefaultODataBatchHandler.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
@@ -158,4 +162,4 @@ public virtual async Task> ParseBatchRequestsAsync(
return requests;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData/Batch/LazyStreamContent.cs b/src/Microsoft.AspNet.OData/Batch/LazyStreamContent.cs
index ff761d2035..dff21c788d 100644
--- a/src/Microsoft.AspNet.OData/Batch/LazyStreamContent.cs
+++ b/src/Microsoft.AspNet.OData/Batch/LazyStreamContent.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.IO;
@@ -43,4 +47,4 @@ protected override bool TryComputeLength(out long length)
return false;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData/Batch/ODataBatchContent.cs b/src/Microsoft.AspNet.OData/Batch/ODataBatchContent.cs
index ba5549d2ed..957f2e48c5 100644
--- a/src/Microsoft.AspNet.OData/Batch/ODataBatchContent.cs
+++ b/src/Microsoft.AspNet.OData/Batch/ODataBatchContent.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData/Batch/ODataBatchHandler.cs b/src/Microsoft.AspNet.OData/Batch/ODataBatchHandler.cs
index cbafe78421..ed88c12660 100644
--- a/src/Microsoft.AspNet.OData/Batch/ODataBatchHandler.cs
+++ b/src/Microsoft.AspNet.OData/Batch/ODataBatchHandler.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
@@ -79,4 +83,4 @@ public virtual Uri GetBaseUri(HttpRequestMessage request)
return request.GetODataBatchBaseUri(ODataRouteName);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData/Batch/ODataBatchHttpRequestMessageExtensions.cs b/src/Microsoft.AspNet.OData/Batch/ODataBatchHttpRequestMessageExtensions.cs
index b42cafc1a8..9fb7a0eab3 100644
--- a/src/Microsoft.AspNet.OData/Batch/ODataBatchHttpRequestMessageExtensions.cs
+++ b/src/Microsoft.AspNet.OData/Batch/ODataBatchHttpRequestMessageExtensions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
@@ -297,4 +301,4 @@ internal static Uri GetODataBatchBaseUri(this HttpRequestMessage request, string
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData/Batch/ODataBatchReaderExtensions.cs b/src/Microsoft.AspNet.OData/Batch/ODataBatchReaderExtensions.cs
index a686d3aafb..338ec0b673 100644
--- a/src/Microsoft.AspNet.OData/Batch/ODataBatchReaderExtensions.cs
+++ b/src/Microsoft.AspNet.OData/Batch/ODataBatchReaderExtensions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
@@ -190,4 +194,4 @@ private static async Task ReadOperationInternalAsync(
return request;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData/Batch/ODataBatchRequestItem.cs b/src/Microsoft.AspNet.OData/Batch/ODataBatchRequestItem.cs
index 7d13125efd..e60032c24d 100644
--- a/src/Microsoft.AspNet.OData/Batch/ODataBatchRequestItem.cs
+++ b/src/Microsoft.AspNet.OData/Batch/ODataBatchRequestItem.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
@@ -99,4 +103,4 @@ public void Dispose()
/// true to release both managed and unmanaged resources; false to release only unmanaged resources.
protected abstract void Dispose(bool disposing);
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData/Batch/ODataBatchResponseItem.cs b/src/Microsoft.AspNet.OData/Batch/ODataBatchResponseItem.cs
index 06195535e2..fb4dbc6d9b 100644
--- a/src/Microsoft.AspNet.OData/Batch/ODataBatchResponseItem.cs
+++ b/src/Microsoft.AspNet.OData/Batch/ODataBatchResponseItem.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
@@ -146,4 +150,4 @@ internal virtual bool IsResponseSuccessful()
/// true to release both managed and unmanaged resources; false to release only unmanaged resources.
protected abstract void Dispose(bool disposing);
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData/Batch/ODataHttpContentExtensions.cs b/src/Microsoft.AspNet.OData/Batch/ODataHttpContentExtensions.cs
index cf05428620..d02cf59ada 100644
--- a/src/Microsoft.AspNet.OData/Batch/ODataHttpContentExtensions.cs
+++ b/src/Microsoft.AspNet.OData/Batch/ODataHttpContentExtensions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.ComponentModel;
@@ -56,4 +60,4 @@ public static async Task GetODataMessageReaderAsync(this Htt
return oDataMessageReader;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData/Batch/OperationRequestItem.cs b/src/Microsoft.AspNet.OData/Batch/OperationRequestItem.cs
index 3ea9d4fa8a..6129771c04 100644
--- a/src/Microsoft.AspNet.OData/Batch/OperationRequestItem.cs
+++ b/src/Microsoft.AspNet.OData/Batch/OperationRequestItem.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
@@ -69,4 +73,4 @@ public override IEnumerable GetResourcesForDisposal()
return Request.GetResourcesForDisposal();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData/Batch/OperationResponseItem.cs b/src/Microsoft.AspNet.OData/Batch/OperationResponseItem.cs
index 131e7c138b..9949e064da 100644
--- a/src/Microsoft.AspNet.OData/Batch/OperationResponseItem.cs
+++ b/src/Microsoft.AspNet.OData/Batch/OperationResponseItem.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Net.Http;
using System.Threading;
@@ -66,4 +70,4 @@ protected override void Dispose(bool disposing)
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData/Batch/UnbufferedODataBatchHandler.cs b/src/Microsoft.AspNet.OData/Batch/UnbufferedODataBatchHandler.cs
index 5ce3bba9e4..311d8d3388 100644
--- a/src/Microsoft.AspNet.OData/Batch/UnbufferedODataBatchHandler.cs
+++ b/src/Microsoft.AspNet.OData/Batch/UnbufferedODataBatchHandler.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
@@ -196,4 +200,4 @@ public virtual async Task ExecuteChangeSetAsync(ODataBat
return new ChangeSetResponseItem(changeSetResponse);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData/Builder/ODataConventionModelBuilder.cs b/src/Microsoft.AspNet.OData/Builder/ODataConventionModelBuilder.cs
index 418681263c..96e0946cb1 100644
--- a/src/Microsoft.AspNet.OData/Builder/ODataConventionModelBuilder.cs
+++ b/src/Microsoft.AspNet.OData/Builder/ODataConventionModelBuilder.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Web.Http;
using System.Web.Http.Dispatcher;
diff --git a/src/Microsoft.AspNet.OData/ETagMessageHandler.cs b/src/Microsoft.AspNet.OData/ETagMessageHandler.cs
index e3b4c97b2e..150625994a 100644
--- a/src/Microsoft.AspNet.OData/ETagMessageHandler.cs
+++ b/src/Microsoft.AspNet.OData/ETagMessageHandler.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Net.Http;
using System.Net.Http.Headers;
diff --git a/src/Microsoft.AspNet.OData/EnableQueryAttribute.cs b/src/Microsoft.AspNet.OData/EnableQueryAttribute.cs
index c40d51a4ab..893605419c 100644
--- a/src/Microsoft.AspNet.OData/EnableQueryAttribute.cs
+++ b/src/Microsoft.AspNet.OData/EnableQueryAttribute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
@@ -195,4 +199,4 @@ public virtual IEdmModel GetModel(Type elementClrType, HttpRequestMessage reques
return model;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData/Extensions/HttpActionDescriptorExtensions.cs b/src/Microsoft.AspNet.OData/Extensions/HttpActionDescriptorExtensions.cs
index 4591903d05..96641d70fd 100644
--- a/src/Microsoft.AspNet.OData/Extensions/HttpActionDescriptorExtensions.cs
+++ b/src/Microsoft.AspNet.OData/Extensions/HttpActionDescriptorExtensions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.ComponentModel;
diff --git a/src/Microsoft.AspNet.OData/Extensions/HttpConfigurationExtensions.cs b/src/Microsoft.AspNet.OData/Extensions/HttpConfigurationExtensions.cs
index 9e2cf70ea5..1f05cd45fa 100644
--- a/src/Microsoft.AspNet.OData/Extensions/HttpConfigurationExtensions.cs
+++ b/src/Microsoft.AspNet.OData/Extensions/HttpConfigurationExtensions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData/Extensions/HttpErrorExtensions.cs b/src/Microsoft.AspNet.OData/Extensions/HttpErrorExtensions.cs
index b50cb314ae..969bd1b1c1 100644
--- a/src/Microsoft.AspNet.OData/Extensions/HttpErrorExtensions.cs
+++ b/src/Microsoft.AspNet.OData/Extensions/HttpErrorExtensions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.ComponentModel;
diff --git a/src/Microsoft.AspNet.OData/Extensions/HttpRequestMessageExtensions.cs b/src/Microsoft.AspNet.OData/Extensions/HttpRequestMessageExtensions.cs
index 64ebbe0532..ca30940751 100644
--- a/src/Microsoft.AspNet.OData/Extensions/HttpRequestMessageExtensions.cs
+++ b/src/Microsoft.AspNet.OData/Extensions/HttpRequestMessageExtensions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData/Extensions/HttpRequestMessageProperties.cs b/src/Microsoft.AspNet.OData/Extensions/HttpRequestMessageProperties.cs
index b4db1f5ab7..17851d1e03 100644
--- a/src/Microsoft.AspNet.OData/Extensions/HttpRequestMessageProperties.cs
+++ b/src/Microsoft.AspNet.OData/Extensions/HttpRequestMessageProperties.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData/Extensions/UrlHelperExtensions.cs b/src/Microsoft.AspNet.OData/Extensions/UrlHelperExtensions.cs
index 5a8019ed36..19c0475a12 100644
--- a/src/Microsoft.AspNet.OData/Extensions/UrlHelperExtensions.cs
+++ b/src/Microsoft.AspNet.OData/Extensions/UrlHelperExtensions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData/Formatter/Deserialization/DefaultODataDeserializerProvider.cs b/src/Microsoft.AspNet.OData/Formatter/Deserialization/DefaultODataDeserializerProvider.cs
index 51ce178032..18f9d1fc94 100644
--- a/src/Microsoft.AspNet.OData/Formatter/Deserialization/DefaultODataDeserializerProvider.cs
+++ b/src/Microsoft.AspNet.OData/Formatter/Deserialization/DefaultODataDeserializerProvider.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Net.Http;
diff --git a/src/Microsoft.AspNet.OData/Formatter/Deserialization/ODataDeserializerContext.cs b/src/Microsoft.AspNet.OData/Formatter/Deserialization/ODataDeserializerContext.cs
index 16ceeb06ed..e71283bba8 100644
--- a/src/Microsoft.AspNet.OData/Formatter/Deserialization/ODataDeserializerContext.cs
+++ b/src/Microsoft.AspNet.OData/Formatter/Deserialization/ODataDeserializerContext.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Net.Http;
using System.Web.Http.Controllers;
diff --git a/src/Microsoft.AspNet.OData/Formatter/Deserialization/ODataDeserializerProvider.cs b/src/Microsoft.AspNet.OData/Formatter/Deserialization/ODataDeserializerProvider.cs
index 963d135c93..b4582e6e55 100644
--- a/src/Microsoft.AspNet.OData/Formatter/Deserialization/ODataDeserializerProvider.cs
+++ b/src/Microsoft.AspNet.OData/Formatter/Deserialization/ODataDeserializerProvider.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Net.Http;
diff --git a/src/Microsoft.AspNet.OData/Formatter/ODataCountMediaTypeMapping.cs b/src/Microsoft.AspNet.OData/Formatter/ODataCountMediaTypeMapping.cs
index effb51e6e8..62be694235 100644
--- a/src/Microsoft.AspNet.OData/Formatter/ODataCountMediaTypeMapping.cs
+++ b/src/Microsoft.AspNet.OData/Formatter/ODataCountMediaTypeMapping.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Net.Http;
using System.Net.Http.Formatting;
diff --git a/src/Microsoft.AspNet.OData/Formatter/ODataMediaTypeFormatter.cs b/src/Microsoft.AspNet.OData/Formatter/ODataMediaTypeFormatter.cs
index a9c0dd4dee..c274da5d8f 100644
--- a/src/Microsoft.AspNet.OData/Formatter/ODataMediaTypeFormatter.cs
+++ b/src/Microsoft.AspNet.OData/Formatter/ODataMediaTypeFormatter.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
@@ -392,4 +396,4 @@ public static Uri GetDefaultBaseAddress(HttpRequestMessage request)
return baseAddress[baseAddress.Length - 1] != '/' ? new Uri(baseAddress + '/') : new Uri(baseAddress);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData/Formatter/ODataMediaTypeFormatters.cs b/src/Microsoft.AspNet.OData/Formatter/ODataMediaTypeFormatters.cs
index 5c1cbdd6cb..7e41709b2f 100644
--- a/src/Microsoft.AspNet.OData/Formatter/ODataMediaTypeFormatters.cs
+++ b/src/Microsoft.AspNet.OData/Formatter/ODataMediaTypeFormatters.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Net.Http.Formatting;
diff --git a/src/Microsoft.AspNet.OData/Formatter/ODataModelBinderProvider.cs b/src/Microsoft.AspNet.OData/Formatter/ODataModelBinderProvider.cs
index 74d50f24d5..90606f0494 100644
--- a/src/Microsoft.AspNet.OData/Formatter/ODataModelBinderProvider.cs
+++ b/src/Microsoft.AspNet.OData/Formatter/ODataModelBinderProvider.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.ComponentModel.DataAnnotations;
diff --git a/src/Microsoft.AspNet.OData/Formatter/ODataRawValueMediaTypeMapping.cs b/src/Microsoft.AspNet.OData/Formatter/ODataRawValueMediaTypeMapping.cs
index 9d1e134784..1912978145 100644
--- a/src/Microsoft.AspNet.OData/Formatter/ODataRawValueMediaTypeMapping.cs
+++ b/src/Microsoft.AspNet.OData/Formatter/ODataRawValueMediaTypeMapping.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Net.Http;
using System.Net.Http.Formatting;
diff --git a/src/Microsoft.AspNet.OData/Formatter/ODataStreamMediaTypeMapping.cs b/src/Microsoft.AspNet.OData/Formatter/ODataStreamMediaTypeMapping.cs
index f45ddde865..a1c54a636d 100644
--- a/src/Microsoft.AspNet.OData/Formatter/ODataStreamMediaTypeMapping.cs
+++ b/src/Microsoft.AspNet.OData/Formatter/ODataStreamMediaTypeMapping.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Net.Http;
using System.Net.Http.Formatting;
diff --git a/src/Microsoft.AspNet.OData/Formatter/QueryStringMediaTypeMapping.cs b/src/Microsoft.AspNet.OData/Formatter/QueryStringMediaTypeMapping.cs
index 3469479365..98cea0889f 100644
--- a/src/Microsoft.AspNet.OData/Formatter/QueryStringMediaTypeMapping.cs
+++ b/src/Microsoft.AspNet.OData/Formatter/QueryStringMediaTypeMapping.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Net.Http;
diff --git a/src/Microsoft.AspNet.OData/Formatter/Serialization/DefaultODataSerializerProvider.cs b/src/Microsoft.AspNet.OData/Formatter/Serialization/DefaultODataSerializerProvider.cs
index 158de73965..0f7f434ab7 100644
--- a/src/Microsoft.AspNet.OData/Formatter/Serialization/DefaultODataSerializerProvider.cs
+++ b/src/Microsoft.AspNet.OData/Formatter/Serialization/DefaultODataSerializerProvider.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Net.Http;
diff --git a/src/Microsoft.AspNet.OData/Formatter/Serialization/ODataErrorSerializer.cs b/src/Microsoft.AspNet.OData/Formatter/Serialization/ODataErrorSerializer.cs
index 3d20d70e37..2a828d4779 100644
--- a/src/Microsoft.AspNet.OData/Formatter/Serialization/ODataErrorSerializer.cs
+++ b/src/Microsoft.AspNet.OData/Formatter/Serialization/ODataErrorSerializer.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Web.Http;
using Microsoft.AspNet.OData.Extensions;
diff --git a/src/Microsoft.AspNet.OData/Formatter/Serialization/ODataSerializerContext.cs b/src/Microsoft.AspNet.OData/Formatter/Serialization/ODataSerializerContext.cs
index 78bb92f55c..386f57586b 100644
--- a/src/Microsoft.AspNet.OData/Formatter/Serialization/ODataSerializerContext.cs
+++ b/src/Microsoft.AspNet.OData/Formatter/Serialization/ODataSerializerContext.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Net.Http;
using System.Web.Http.Controllers;
diff --git a/src/Microsoft.AspNet.OData/Formatter/Serialization/ODataSerializerProvider.cs b/src/Microsoft.AspNet.OData/Formatter/Serialization/ODataSerializerProvider.cs
index 0506d43a1c..06d112c003 100644
--- a/src/Microsoft.AspNet.OData/Formatter/Serialization/ODataSerializerProvider.cs
+++ b/src/Microsoft.AspNet.OData/Formatter/Serialization/ODataSerializerProvider.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Net.Http;
diff --git a/src/Microsoft.AspNet.OData/FromODataUriAttribute.cs b/src/Microsoft.AspNet.OData/FromODataUriAttribute.cs
index e471bbf805..51edbda157 100644
--- a/src/Microsoft.AspNet.OData/FromODataUriAttribute.cs
+++ b/src/Microsoft.AspNet.OData/FromODataUriAttribute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData/GetNextPageHelper.cs b/src/Microsoft.AspNet.OData/GetNextPageHelper.cs
index fdf77fe483..45a7de7d9c 100644
--- a/src/Microsoft.AspNet.OData/GetNextPageHelper.cs
+++ b/src/Microsoft.AspNet.OData/GetNextPageHelper.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Diagnostics.Contracts;
diff --git a/src/Microsoft.AspNet.OData/GlobalSuppressions.cs b/src/Microsoft.AspNet.OData/GlobalSuppressions.cs
index bebd2a6b5b..a4a7b94422 100644
--- a/src/Microsoft.AspNet.OData/GlobalSuppressions.cs
+++ b/src/Microsoft.AspNet.OData/GlobalSuppressions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Diagnostics.CodeAnalysis;
@@ -61,3 +65,35 @@
[assembly: SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Scope = "member", Target = "Microsoft.AspNet.OData.Builder.IODataInstanceAnnotationContainer.#GetAllResourceAnnotations()")]
[assembly: SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Scope = "member", Target = "Microsoft.AspNet.OData.Builder.IODataInstanceAnnotationContainer.#GetResourceAnnotations()")]
[assembly: SuppressMessage("Microsoft.Usage", "CA2208:InstantiateArgumentExceptionsCorrectly", Scope = "member", Target = "Microsoft.AspNet.OData.Common.Error.#PropertyNullOrWhiteSpace()")]
+[assembly: SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes", Scope = "member", Target = "Microsoft.AspNet.OData.Delta`1.#Microsoft.AspNet.OData.IEdmObject.GetEdmType()")]
+[assembly: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Upsert", Scope = "member", Target = "Microsoft.AspNet.OData.DataModificationOperationKind.#Upsert")]
+[assembly: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Upsert", Scope = "member", Target = "Org.OData.Core.V1.DataModificationOperationKind.#Upsert")]
+[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "Org.OData.Core.V1")]
+[assembly: SuppressMessage("Microsoft.Design", "CA1040:AvoidEmptyInterfaces", Scope = "type", Target = "Microsoft.AspNet.OData.IDeltaSet")]
+[assembly: SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "2#", Scope = "member", Target = "Microsoft.AspNet.OData.ODataAPIHandler`1.#TryGet(System.Collections.Generic.IDictionary`2,!0&,System.String&)")]
+[assembly: SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "1#", Scope = "member", Target = "Microsoft.AspNet.OData.ODataAPIHandler`1.#TryDelete(System.Collections.Generic.IDictionary`2,System.String&)")]
+[assembly: SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "1#", Scope = "member", Target = "Microsoft.AspNet.OData.ODataAPIHandler`1.#TryGet(System.Collections.Generic.IDictionary`2,!0&,System.String&)")]
+[assembly: SuppressMessage("Microsoft.Design", "CA1040:AvoidEmptyInterfaces", Scope = "type", Target = "Microsoft.AspNet.OData.IODataAPIHandler")]
+[assembly: SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling", Scope = "member", Target = "Microsoft.AspNet.OData.Formatter.Serialization.DefaultODataSerializerProvider.#GetODataPayloadSerializerImpl(System.Type,System.Func`1,Microsoft.AspNet.OData.Routing.ODataPath,System.Type)")]
+[assembly: SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "1#", Scope = "member", Target = "Microsoft.AspNet.OData.EdmODataAPIHandler.#TryDelete(System.Collections.Generic.IDictionary`2,System.String&)")]
+[assembly: SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "1#", Scope = "member", Target = "Microsoft.AspNet.OData.EdmODataAPIHandler.#TryGet(System.Collections.Generic.IDictionary`2,Microsoft.AspNet.OData.EdmStructuredObject&,System.String&)")]
+[assembly: SuppressMessage("Microsoft.Globalization", "CA1305:SpecifyIFormatProvider", MessageId = "System.String.Format(System.String,System.Object,System.Object)", Scope = "member", Target = "Microsoft.AspNet.OData.Formatter.ClrTypeCache+EdmTypeCacheItemComparer.#GetHashCode(Microsoft.AspNet.OData.Formatter.ClrTypeCache+EdmTypeCacheItem)")]
+[assembly: SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "1#", Scope = "member", Target = "Microsoft.AspNet.OData.EdmODataAPIHandler.#TryCreate(Microsoft.AspNet.OData.IEdmChangedObject,Microsoft.AspNet.OData.IEdmStructuredObject&,System.String&)")]
+[assembly: SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "2#", Scope = "member", Target = "Microsoft.AspNet.OData.EdmODataAPIHandler.#TryCreate(Microsoft.AspNet.OData.IEdmChangedObject,Microsoft.AspNet.OData.IEdmStructuredObject&,System.String&)")]
+[assembly: SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "2#", Scope = "member", Target = "Microsoft.AspNet.OData.EdmODataAPIHandler.#TryGet(System.Collections.Generic.IDictionary`2,Microsoft.AspNet.OData.IEdmStructuredObject&,System.String&)")]
+[assembly: SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "1#", Scope = "member", Target = "Microsoft.AspNet.OData.EdmODataAPIHandler.#TryGet(System.Collections.Generic.IDictionary`2,Microsoft.AspNet.OData.IEdmStructuredObject&,System.String&)")]
+[assembly: SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Scope = "member", Target = "Microsoft.AspNet.OData.EdmDeltaDeletedEntityObject.#_edmType")]
+[assembly: SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Scope = "member", Target = "Microsoft.AspNet.OData.EdmDeltaDeletedLink.#_edmType")]
+[assembly: SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Scope = "member", Target = "Microsoft.AspNet.OData.EdmDeltaEntityObject.#_edmType")]
+[assembly: SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Scope = "member", Target = "Microsoft.AspNet.OData.EdmDeltaLink.#_edmType")]
+[assembly: SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "Microsoft.AspNet.OData.Formatter.Deserialization.ODataResourceDeserializer.#CreateKeyProperties(System.Uri,Microsoft.AspNet.OData.Formatter.Deserialization.ODataDeserializerContext)")]
+[assembly: SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.AspNet.OData.Formatter.Deserialization.ODataResourceDeserializer.#CreateResourceWrapper(Microsoft.OData.Edm.IEdmTypeReference,Microsoft.AspNet.OData.Formatter.Deserialization.ODataEntityReferenceLinkBase,Microsoft.AspNet.OData.Formatter.Deserialization.ODataDeserializerContext)")]
+[assembly: SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.AspNet.OData.Formatter.Deserialization.ODataResourceDeserializer.#UpdateResourceWrapper(Microsoft.AspNet.OData.Formatter.Deserialization.ODataResourceWrapper,Microsoft.AspNet.OData.Formatter.Deserialization.ODataDeserializerContext)")]
+[assembly: SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling", Scope = "member", Target = "Microsoft.AspNet.OData.Delta`1.#CopyChangedValues(!0,Microsoft.AspNet.OData.ODataAPIHandler`1,Microsoft.AspNet.OData.ODataAPIHandlerFactory)")]
+[assembly: SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "Microsoft.AspNet.OData.Formatter.Deserialization.ODataResourceDeserializer.#GetODataPath(System.String,Microsoft.AspNet.OData.Formatter.Deserialization.ODataDeserializerContext)")]
+[assembly: SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "API", Scope = "type", Target = "Microsoft.AspNet.OData.ODataAPIHandler`1")]
+[assembly: SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "API", Scope = "type", Target = "Microsoft.AspNet.OData.IODataAPIHandler")]
+[assembly: SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "API", Scope = "type", Target = "Microsoft.AspNet.OData.ODataEdmAPIHandlerFactory")]
+[assembly: SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "API", Scope = "type", Target = "Microsoft.AspNet.OData.ODataAPIResponseStatus")]
+[assembly: SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "API", Scope = "type", Target = "Microsoft.AspNet.OData.EdmODataAPIHandler")]
+[assembly: SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "API", Scope = "type", Target = "Microsoft.AspNet.OData.ODataAPIHandlerFactory")]
diff --git a/src/Microsoft.AspNet.OData/HttpRequestScope.cs b/src/Microsoft.AspNet.OData/HttpRequestScope.cs
index 7717cfae39..7e34d9f46c 100644
--- a/src/Microsoft.AspNet.OData/HttpRequestScope.cs
+++ b/src/Microsoft.AspNet.OData/HttpRequestScope.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Net.Http;
diff --git a/src/Microsoft.AspNet.OData/Microsoft.AspNet.OData.Nightly.Release.nuspec b/src/Microsoft.AspNet.OData/Microsoft.AspNet.OData.Nightly.nuspec
similarity index 80%
rename from src/Microsoft.AspNet.OData/Microsoft.AspNet.OData.Nightly.Release.nuspec
rename to src/Microsoft.AspNet.OData/Microsoft.AspNet.OData.Nightly.nuspec
index eb31988526..4ce723cb59 100644
--- a/src/Microsoft.AspNet.OData/Microsoft.AspNet.OData.Nightly.Release.nuspec
+++ b/src/Microsoft.AspNet.OData/Microsoft.AspNet.OData.Nightly.nuspec
@@ -3,17 +3,18 @@
Microsoft.AspNet.OData
Microsoft ASP.NET Web API 2.2 for OData v4.0
- $VersionFullSemantic$-Nightly$NightlyBuildVersion$
- Microsoft
- © Microsoft Corporation. All rights reserved.
+ $VersionNuGetSemantic$-Nightly$NightlyBuildVersion$
+ OData (.NET Foundation)
+ © .NET Foundation and Contributors. All rights reserved.
This package contains everything you need to create OData v4.0 endpoints using ASP.NET Web API and to support OData query syntax for your web APIs.
This package contains everything you need to create OData v4.0 endpoints using ASP.NET Web API.
en-US
http://odata.github.io
- https://raw.githubusercontent.com/OData/WebApi/master/License.txt
+ MIT
true
Microsoft AspNet WebApi AspNetWebApi OData
- http://static.tumblr.com/hgchgxz/9ualgdf98/icon.png
+ images\odata.png
+
@@ -31,5 +32,6 @@
+
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.OData/Microsoft.AspNet.OData.Release.nuspec b/src/Microsoft.AspNet.OData/Microsoft.AspNet.OData.Release.nuspec
index ad6592619b..dbb138fc74 100644
--- a/src/Microsoft.AspNet.OData/Microsoft.AspNet.OData.Release.nuspec
+++ b/src/Microsoft.AspNet.OData/Microsoft.AspNet.OData.Release.nuspec
@@ -4,17 +4,18 @@
Microsoft.AspNet.OData
Microsoft ASP.NET Web API 2.2 for OData v4.0
$VersionNuGetSemantic$
- Microsoft
- © Microsoft Corporation. All rights reserved.
+ OData (.NET Foundation)
+ © .NET Foundation and Contributors. All rights reserved.
This package contains everything you need to create OData v4.0 endpoints using ASP.NET Web API and to support OData query syntax for your web APIs.
This package contains everything you need to create OData v4.0 endpoints using ASP.NET Web API.
https://docs.microsoft.com/en-us/odata/changelog/webapi-7x
en-US
http://odata.github.io
- https://raw.githubusercontent.com/OData/WebApi/master/License.txt
+ MIT
true
Microsoft AspNet WebApi AspNetWebApi OData
- http://static.tumblr.com/hgchgxz/9ualgdf98/icon.png
+ images\odata.png
+
@@ -32,5 +33,6 @@
+
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.OData/Microsoft.AspNet.OData.csproj b/src/Microsoft.AspNet.OData/Microsoft.AspNet.OData.csproj
index 032dcfc4aa..f815b8ad52 100644
--- a/src/Microsoft.AspNet.OData/Microsoft.AspNet.OData.csproj
+++ b/src/Microsoft.AspNet.OData/Microsoft.AspNet.OData.csproj
@@ -30,14 +30,14 @@
..\..\sln\packages\Microsoft.Extensions.DependencyInjection.Abstractions.1.0.0\lib\netstandard1.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll
True
-
- ..\..\sln\packages\Microsoft.OData.Core.7.9.0\lib\net45\Microsoft.OData.Core.dll
+
+ ..\..\sln\packages\Microsoft.OData.Core.7.9.1\lib\net45\Microsoft.OData.Core.dll
-
- ..\..\sln\packages\Microsoft.OData.Edm.7.9.0\lib\net45\Microsoft.OData.Edm.dll
+
+ ..\..\sln\packages\Microsoft.OData.Edm.7.9.1\lib\net45\Microsoft.OData.Edm.dll
-
- ..\..\sln\packages\Microsoft.Spatial.7.9.0\lib\net45\Microsoft.Spatial.dll
+
+ ..\..\sln\packages\Microsoft.Spatial.7.9.1\lib\net45\Microsoft.Spatial.dll
..\..\sln\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll
diff --git a/src/Microsoft.AspNet.OData/NonValidatingParameterBindingAttribute.cs b/src/Microsoft.AspNet.OData/NonValidatingParameterBindingAttribute.cs
index f3c165ed9e..d2947c5e08 100644
--- a/src/Microsoft.AspNet.OData/NonValidatingParameterBindingAttribute.cs
+++ b/src/Microsoft.AspNet.OData/NonValidatingParameterBindingAttribute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData/ODataController.cs b/src/Microsoft.AspNet.OData/ODataController.cs
index 34d6bbd99e..bbdcd80870 100644
--- a/src/Microsoft.AspNet.OData/ODataController.cs
+++ b/src/Microsoft.AspNet.OData/ODataController.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Web.Http;
using System.Web.Http.Description;
diff --git a/src/Microsoft.AspNet.OData/ODataFormattingAttribute.cs b/src/Microsoft.AspNet.OData/ODataFormattingAttribute.cs
index 52112eddd9..a132335722 100644
--- a/src/Microsoft.AspNet.OData/ODataFormattingAttribute.cs
+++ b/src/Microsoft.AspNet.OData/ODataFormattingAttribute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData/ODataMessageWrapperHelper.cs b/src/Microsoft.AspNet.OData/ODataMessageWrapperHelper.cs
index 8e954dd882..21397448ef 100644
--- a/src/Microsoft.AspNet.OData/ODataMessageWrapperHelper.cs
+++ b/src/Microsoft.AspNet.OData/ODataMessageWrapperHelper.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData/ODataNullValueMessageHandler.cs b/src/Microsoft.AspNet.OData/ODataNullValueMessageHandler.cs
index b6ce56fc0a..6ae28c34db 100644
--- a/src/Microsoft.AspNet.OData/ODataNullValueMessageHandler.cs
+++ b/src/Microsoft.AspNet.OData/ODataNullValueMessageHandler.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Net;
using System.Net.Http;
diff --git a/src/Microsoft.AspNet.OData/ODataQueryParameterBindingAttribute.cs b/src/Microsoft.AspNet.OData/ODataQueryParameterBindingAttribute.cs
index 559d05fe54..ff5da85c8b 100644
--- a/src/Microsoft.AspNet.OData/ODataQueryParameterBindingAttribute.cs
+++ b/src/Microsoft.AspNet.OData/ODataQueryParameterBindingAttribute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Diagnostics.CodeAnalysis;
diff --git a/src/Microsoft.AspNet.OData/ODataRoutingAttribute.cs b/src/Microsoft.AspNet.OData/ODataRoutingAttribute.cs
index 58f4970dec..132d296330 100644
--- a/src/Microsoft.AspNet.OData/ODataRoutingAttribute.cs
+++ b/src/Microsoft.AspNet.OData/ODataRoutingAttribute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Diagnostics.Contracts;
@@ -48,4 +52,4 @@ public void Initialize(HttpControllerSettings controllerSettings, HttpController
services.Insert(typeof(ValueProviderFactory), 0, new ODataValueProviderFactory());
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData/PerRequestActionValueBinder.cs b/src/Microsoft.AspNet.OData/PerRequestActionValueBinder.cs
index af8ff66d1a..bcda9e5805 100644
--- a/src/Microsoft.AspNet.OData/PerRequestActionValueBinder.cs
+++ b/src/Microsoft.AspNet.OData/PerRequestActionValueBinder.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Diagnostics.Contracts;
using System.Web.Http.Controllers;
diff --git a/src/Microsoft.AspNet.OData/PerRequestContentNegotiator.cs b/src/Microsoft.AspNet.OData/PerRequestContentNegotiator.cs
index e72d6419fe..04473a476a 100644
--- a/src/Microsoft.AspNet.OData/PerRequestContentNegotiator.cs
+++ b/src/Microsoft.AspNet.OData/PerRequestContentNegotiator.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData/PerRequestParameterBinding.cs b/src/Microsoft.AspNet.OData/PerRequestParameterBinding.cs
index 553e6a7078..320d92f709 100644
--- a/src/Microsoft.AspNet.OData/PerRequestParameterBinding.cs
+++ b/src/Microsoft.AspNet.OData/PerRequestParameterBinding.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Diagnostics.Contracts;
diff --git a/src/Microsoft.AspNet.OData/PerRouteContainer.cs b/src/Microsoft.AspNet.OData/PerRouteContainer.cs
index 502de2ec2f..8f118bfc16 100644
--- a/src/Microsoft.AspNet.OData/PerRouteContainer.cs
+++ b/src/Microsoft.AspNet.OData/PerRouteContainer.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Concurrent;
diff --git a/src/Microsoft.AspNet.OData/Properties/AssemblyInfo.cs b/src/Microsoft.AspNet.OData/Properties/AssemblyInfo.cs
index 9520935151..4bd46c88f7 100644
--- a/src/Microsoft.AspNet.OData/Properties/AssemblyInfo.cs
+++ b/src/Microsoft.AspNet.OData/Properties/AssemblyInfo.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Reflection;
using System.Runtime.CompilerServices;
diff --git a/src/Microsoft.AspNet.OData/Query/ODataQueryOptions.cs b/src/Microsoft.AspNet.OData/Query/ODataQueryOptions.cs
index 77d66d7185..d7ea0e6fa2 100644
--- a/src/Microsoft.AspNet.OData/Query/ODataQueryOptions.cs
+++ b/src/Microsoft.AspNet.OData/Query/ODataQueryOptions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Diagnostics.Contracts;
using System.Net.Http;
diff --git a/src/Microsoft.AspNet.OData/Query/ODataQueryOptionsOfTEntity.cs b/src/Microsoft.AspNet.OData/Query/ODataQueryOptionsOfTEntity.cs
index 682fe44c8d..60382e9c69 100644
--- a/src/Microsoft.AspNet.OData/Query/ODataQueryOptionsOfTEntity.cs
+++ b/src/Microsoft.AspNet.OData/Query/ODataQueryOptionsOfTEntity.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Net.Http;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNet.OData/Query/PlainTextODataQueryOptionsParser.cs b/src/Microsoft.AspNet.OData/Query/PlainTextODataQueryOptionsParser.cs
index 0641e397fa..f33f64fb22 100644
--- a/src/Microsoft.AspNet.OData/Query/PlainTextODataQueryOptionsParser.cs
+++ b/src/Microsoft.AspNet.OData/Query/PlainTextODataQueryOptionsParser.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Diagnostics.CodeAnalysis;
diff --git a/src/Microsoft.AspNet.OData/Query/QueryFilterProvider.cs b/src/Microsoft.AspNet.OData/Query/QueryFilterProvider.cs
index e11ce94009..ae9c1b462e 100644
--- a/src/Microsoft.AspNet.OData/Query/QueryFilterProvider.cs
+++ b/src/Microsoft.AspNet.OData/Query/QueryFilterProvider.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Linq;
diff --git a/src/Microsoft.AspNet.OData/ResourceContext.cs b/src/Microsoft.AspNet.OData/ResourceContext.cs
index b467ff7b5a..81e32fcf22 100644
--- a/src/Microsoft.AspNet.OData/ResourceContext.cs
+++ b/src/Microsoft.AspNet.OData/ResourceContext.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Net.Http;
using System.Web.Http.Routing;
diff --git a/src/Microsoft.AspNet.OData/ResourceSetContext.cs b/src/Microsoft.AspNet.OData/ResourceSetContext.cs
index 0ad2118ea0..70ffe8a22d 100644
--- a/src/Microsoft.AspNet.OData/ResourceSetContext.cs
+++ b/src/Microsoft.AspNet.OData/ResourceSetContext.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections;
using System.Net.Http;
diff --git a/src/Microsoft.AspNet.OData/Results/CreatedODataResult.cs b/src/Microsoft.AspNet.OData/Results/CreatedODataResult.cs
index a2030a7660..4f563b1696 100644
--- a/src/Microsoft.AspNet.OData/Results/CreatedODataResult.cs
+++ b/src/Microsoft.AspNet.OData/Results/CreatedODataResult.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData/Results/ResultHelpers.cs b/src/Microsoft.AspNet.OData/Results/ResultHelpers.cs
index d77e88a95c..b252a447a8 100644
--- a/src/Microsoft.AspNet.OData/Results/ResultHelpers.cs
+++ b/src/Microsoft.AspNet.OData/Results/ResultHelpers.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Net;
diff --git a/src/Microsoft.AspNet.OData/Results/UpdatedODataResult.cs b/src/Microsoft.AspNet.OData/Results/UpdatedODataResult.cs
index d9a5b5c6ab..dd9f4ef4ed 100644
--- a/src/Microsoft.AspNet.OData/Results/UpdatedODataResult.cs
+++ b/src/Microsoft.AspNet.OData/Results/UpdatedODataResult.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData/Routing/Conventions/ActionRoutingConvention.cs b/src/Microsoft.AspNet.OData/Routing/Conventions/ActionRoutingConvention.cs
index bb75d7467e..3fe1d77c26 100644
--- a/src/Microsoft.AspNet.OData/Routing/Conventions/ActionRoutingConvention.cs
+++ b/src/Microsoft.AspNet.OData/Routing/Conventions/ActionRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Linq;
using System.Web.Http.Controllers;
diff --git a/src/Microsoft.AspNet.OData/Routing/Conventions/AttributeRoutingConvention.cs b/src/Microsoft.AspNet.OData/Routing/Conventions/AttributeRoutingConvention.cs
index d3742c4249..313268b4bb 100644
--- a/src/Microsoft.AspNet.OData/Routing/Conventions/AttributeRoutingConvention.cs
+++ b/src/Microsoft.AspNet.OData/Routing/Conventions/AttributeRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData/Routing/Conventions/DynamicPropertyRoutingConvention.cs b/src/Microsoft.AspNet.OData/Routing/Conventions/DynamicPropertyRoutingConvention.cs
index e3c0a91230..cbe9c15adc 100644
--- a/src/Microsoft.AspNet.OData/Routing/Conventions/DynamicPropertyRoutingConvention.cs
+++ b/src/Microsoft.AspNet.OData/Routing/Conventions/DynamicPropertyRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Diagnostics.CodeAnalysis;
using System.Linq;
@@ -26,4 +30,4 @@ public override string SelectAction(ODataPath odataPath, HttpControllerContext c
new WebApiActionMap(actionMap));
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData/Routing/Conventions/EntityRoutingConvention.cs b/src/Microsoft.AspNet.OData/Routing/Conventions/EntityRoutingConvention.cs
index 253cf0cc5d..438251b082 100644
--- a/src/Microsoft.AspNet.OData/Routing/Conventions/EntityRoutingConvention.cs
+++ b/src/Microsoft.AspNet.OData/Routing/Conventions/EntityRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Linq;
using System.Web.Http.Controllers;
diff --git a/src/Microsoft.AspNet.OData/Routing/Conventions/EntitySetRoutingConvention.cs b/src/Microsoft.AspNet.OData/Routing/Conventions/EntitySetRoutingConvention.cs
index f7a5c8dc9a..b3e34b32c7 100644
--- a/src/Microsoft.AspNet.OData/Routing/Conventions/EntitySetRoutingConvention.cs
+++ b/src/Microsoft.AspNet.OData/Routing/Conventions/EntitySetRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Linq;
using System.Web.Http.Controllers;
diff --git a/src/Microsoft.AspNet.OData/Routing/Conventions/FunctionRoutingConvention.cs b/src/Microsoft.AspNet.OData/Routing/Conventions/FunctionRoutingConvention.cs
index 380e0de7c6..cddbe60d69 100644
--- a/src/Microsoft.AspNet.OData/Routing/Conventions/FunctionRoutingConvention.cs
+++ b/src/Microsoft.AspNet.OData/Routing/Conventions/FunctionRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Diagnostics.CodeAnalysis;
using System.Linq;
diff --git a/src/Microsoft.AspNet.OData/Routing/Conventions/IODataRoutingConvention.cs b/src/Microsoft.AspNet.OData/Routing/Conventions/IODataRoutingConvention.cs
index 7cc67baa1e..0e9e1920fe 100644
--- a/src/Microsoft.AspNet.OData/Routing/Conventions/IODataRoutingConvention.cs
+++ b/src/Microsoft.AspNet.OData/Routing/Conventions/IODataRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Diagnostics.CodeAnalysis;
using System.Linq;
@@ -32,4 +36,4 @@ public interface IODataRoutingConvention
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "odata", Justification = "odata is spelled correctly")]
string SelectAction(ODataPath odataPath, HttpControllerContext controllerContext, ILookup actionMap);
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData/Routing/Conventions/MetadataRoutingConvention.cs b/src/Microsoft.AspNet.OData/Routing/Conventions/MetadataRoutingConvention.cs
index 54aa07170f..32ef17eb1b 100644
--- a/src/Microsoft.AspNet.OData/Routing/Conventions/MetadataRoutingConvention.cs
+++ b/src/Microsoft.AspNet.OData/Routing/Conventions/MetadataRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Linq;
using System.Net.Http;
@@ -68,4 +72,4 @@ public string SelectAction(ODataPath odataPath, HttpControllerContext controller
new WebApiActionMap(actionMap));
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData/Routing/Conventions/NavigationRoutingConvention.cs b/src/Microsoft.AspNet.OData/Routing/Conventions/NavigationRoutingConvention.cs
index 6321f56e2e..b040bb0153 100644
--- a/src/Microsoft.AspNet.OData/Routing/Conventions/NavigationRoutingConvention.cs
+++ b/src/Microsoft.AspNet.OData/Routing/Conventions/NavigationRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Linq;
using System.Web.Http.Controllers;
diff --git a/src/Microsoft.AspNet.OData/Routing/Conventions/NavigationSourceRoutingConvention.cs b/src/Microsoft.AspNet.OData/Routing/Conventions/NavigationSourceRoutingConvention.cs
index c34d857615..853f3e3c52 100644
--- a/src/Microsoft.AspNet.OData/Routing/Conventions/NavigationSourceRoutingConvention.cs
+++ b/src/Microsoft.AspNet.OData/Routing/Conventions/NavigationSourceRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Linq;
diff --git a/src/Microsoft.AspNet.OData/Routing/Conventions/ODataRoutingConventions.cs b/src/Microsoft.AspNet.OData/Routing/Conventions/ODataRoutingConventions.cs
index 2969f99865..4db3647584 100644
--- a/src/Microsoft.AspNet.OData/Routing/Conventions/ODataRoutingConventions.cs
+++ b/src/Microsoft.AspNet.OData/Routing/Conventions/ODataRoutingConventions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Web.Http;
@@ -61,4 +65,4 @@ public static IList CreateDefault()
};
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData/Routing/Conventions/OperationImportRoutingConvention.cs b/src/Microsoft.AspNet.OData/Routing/Conventions/OperationImportRoutingConvention.cs
index d80829b079..3b672c9261 100644
--- a/src/Microsoft.AspNet.OData/Routing/Conventions/OperationImportRoutingConvention.cs
+++ b/src/Microsoft.AspNet.OData/Routing/Conventions/OperationImportRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Diagnostics.CodeAnalysis;
using System.Linq;
diff --git a/src/Microsoft.AspNet.OData/Routing/Conventions/PropertyRoutingConvention.cs b/src/Microsoft.AspNet.OData/Routing/Conventions/PropertyRoutingConvention.cs
index 9106aeef75..a8dba30fe0 100644
--- a/src/Microsoft.AspNet.OData/Routing/Conventions/PropertyRoutingConvention.cs
+++ b/src/Microsoft.AspNet.OData/Routing/Conventions/PropertyRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Linq;
using System.Web.Http.Controllers;
diff --git a/src/Microsoft.AspNet.OData/Routing/Conventions/RefRoutingConvention.cs b/src/Microsoft.AspNet.OData/Routing/Conventions/RefRoutingConvention.cs
index b90766a4a9..f27742ee04 100644
--- a/src/Microsoft.AspNet.OData/Routing/Conventions/RefRoutingConvention.cs
+++ b/src/Microsoft.AspNet.OData/Routing/Conventions/RefRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Linq;
using System.Web.Http.Controllers;
@@ -23,4 +27,4 @@ public override string SelectAction(ODataPath odataPath, HttpControllerContext c
new WebApiActionMap(actionMap));
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData/Routing/Conventions/SingletonRoutingConvention.cs b/src/Microsoft.AspNet.OData/Routing/Conventions/SingletonRoutingConvention.cs
index 8a34078eff..4342c1e413 100644
--- a/src/Microsoft.AspNet.OData/Routing/Conventions/SingletonRoutingConvention.cs
+++ b/src/Microsoft.AspNet.OData/Routing/Conventions/SingletonRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Linq;
using System.Web.Http.Controllers;
diff --git a/src/Microsoft.AspNet.OData/Routing/Conventions/UnmappedRequestRoutingConvention.cs b/src/Microsoft.AspNet.OData/Routing/Conventions/UnmappedRequestRoutingConvention.cs
index 042310e1ee..0a3c8819c5 100644
--- a/src/Microsoft.AspNet.OData/Routing/Conventions/UnmappedRequestRoutingConvention.cs
+++ b/src/Microsoft.AspNet.OData/Routing/Conventions/UnmappedRequestRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Linq;
using System.Web.Http.Controllers;
diff --git a/src/Microsoft.AspNet.OData/Routing/ODataActionSelector.cs b/src/Microsoft.AspNet.OData/Routing/ODataActionSelector.cs
index 7ffc59c5a9..97ed3d8f2e 100644
--- a/src/Microsoft.AspNet.OData/Routing/ODataActionSelector.cs
+++ b/src/Microsoft.AspNet.OData/Routing/ODataActionSelector.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData/Routing/ODataPathParameterBindingAttribute.cs b/src/Microsoft.AspNet.OData/Routing/ODataPathParameterBindingAttribute.cs
index dd8cb290c1..3c3c2341e4 100644
--- a/src/Microsoft.AspNet.OData/Routing/ODataPathParameterBindingAttribute.cs
+++ b/src/Microsoft.AspNet.OData/Routing/ODataPathParameterBindingAttribute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Net.Http;
diff --git a/src/Microsoft.AspNet.OData/Routing/ODataPathRouteConstraint.cs b/src/Microsoft.AspNet.OData/Routing/ODataPathRouteConstraint.cs
index a44ce688f8..952f627cb1 100644
--- a/src/Microsoft.AspNet.OData/Routing/ODataPathRouteConstraint.cs
+++ b/src/Microsoft.AspNet.OData/Routing/ODataPathRouteConstraint.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNet.OData/Routing/ODataRoute.cs b/src/Microsoft.AspNet.OData/Routing/ODataRoute.cs
index 305f8e1f5a..6ff0521f22 100644
--- a/src/Microsoft.AspNet.OData/Routing/ODataRoute.cs
+++ b/src/Microsoft.AspNet.OData/Routing/ODataRoute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
@@ -158,4 +162,4 @@ internal HttpVirtualPathData GenerateLinkDirectly(string odataPath)
return new HttpVirtualPathData(this, link);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNet.OData/Routing/ODataValueProviderFactory.cs b/src/Microsoft.AspNet.OData/Routing/ODataValueProviderFactory.cs
index bacd3aa7d6..4ded99772e 100644
--- a/src/Microsoft.AspNet.OData/Routing/ODataValueProviderFactory.cs
+++ b/src/Microsoft.AspNet.OData/Routing/ODataValueProviderFactory.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Globalization;
diff --git a/src/Microsoft.AspNet.OData/Routing/ODataVersionConstraint.cs b/src/Microsoft.AspNet.OData/Routing/ODataVersionConstraint.cs
index cf67ab47e0..2012b11d94 100644
--- a/src/Microsoft.AspNet.OData/Routing/ODataVersionConstraint.cs
+++ b/src/Microsoft.AspNet.OData/Routing/ODataVersionConstraint.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Linq;
diff --git a/src/Microsoft.AspNet.OData/packages.config b/src/Microsoft.AspNet.OData/packages.config
index 40a9177be6..6ff30a8060 100644
--- a/src/Microsoft.AspNet.OData/packages.config
+++ b/src/Microsoft.AspNet.OData/packages.config
@@ -5,10 +5,10 @@
-
-
+
+
-
+
\ No newline at end of file
diff --git a/src/Microsoft.AspNetCore.OData/Adapters/WebApiActionDescriptor.cs b/src/Microsoft.AspNetCore.OData/Adapters/WebApiActionDescriptor.cs
index a1d738687a..964d6febcf 100644
--- a/src/Microsoft.AspNetCore.OData/Adapters/WebApiActionDescriptor.cs
+++ b/src/Microsoft.AspNetCore.OData/Adapters/WebApiActionDescriptor.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
@@ -112,7 +116,7 @@ public string ActionName
/// A list of attributes of type T.
public IEnumerable GetCustomAttributes(bool inherit) where T : Attribute
{
- return this.innerDescriptor.ControllerTypeInfo.GetCustomAttributes(inherit);
+ return this.innerDescriptor.MethodInfo.GetCustomAttributes(inherit);
}
///
diff --git a/src/Microsoft.AspNetCore.OData/Adapters/WebApiActionMap.cs b/src/Microsoft.AspNetCore.OData/Adapters/WebApiActionMap.cs
index 5a10816d61..c726b81885 100644
--- a/src/Microsoft.AspNetCore.OData/Adapters/WebApiActionMap.cs
+++ b/src/Microsoft.AspNetCore.OData/Adapters/WebApiActionMap.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
@@ -43,5 +47,18 @@ public bool Contains(string name)
{
return this.innerMap.Any(a => String.Equals(a.ActionName, name, StringComparison.InvariantCultureIgnoreCase));
}
+
+ ///
+ /// Gets the action descriptor of the specified action
+ ///
+ /// The name of the action
+ /// The if it exists, otherwise null
+ public IWebApiActionDescriptor GetActionDescriptor(string actionName)
+ {
+ ControllerActionDescriptor innerDescriptor = this.innerMap.FirstOrDefault(
+ a => string.Equals(a.ActionName, actionName, StringComparison.InvariantCultureIgnoreCase));
+
+ return innerDescriptor == null ? null : new WebApiActionDescriptor(innerDescriptor);
+ }
}
}
diff --git a/src/Microsoft.AspNetCore.OData/Adapters/WebApiAssembliesResolver.cs b/src/Microsoft.AspNetCore.OData/Adapters/WebApiAssembliesResolver.cs
index 253815c9a3..41f66d9028 100644
--- a/src/Microsoft.AspNetCore.OData/Adapters/WebApiAssembliesResolver.cs
+++ b/src/Microsoft.AspNetCore.OData/Adapters/WebApiAssembliesResolver.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNetCore.OData/Adapters/WebApiContext.cs b/src/Microsoft.AspNetCore.OData/Adapters/WebApiContext.cs
index 7b013021ec..8534de3028 100644
--- a/src/Microsoft.AspNetCore.OData/Adapters/WebApiContext.cs
+++ b/src/Microsoft.AspNetCore.OData/Adapters/WebApiContext.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNetCore.OData/Adapters/WebApiControllerContext.cs b/src/Microsoft.AspNetCore.OData/Adapters/WebApiControllerContext.cs
index b89d135d7c..d6f3d7e049 100644
--- a/src/Microsoft.AspNetCore.OData/Adapters/WebApiControllerContext.cs
+++ b/src/Microsoft.AspNetCore.OData/Adapters/WebApiControllerContext.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNetCore.OData/Adapters/WebApiOptions.cs b/src/Microsoft.AspNetCore.OData/Adapters/WebApiOptions.cs
index 6586a6df8f..00864bef67 100644
--- a/src/Microsoft.AspNetCore.OData/Adapters/WebApiOptions.cs
+++ b/src/Microsoft.AspNetCore.OData/Adapters/WebApiOptions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Common;
using Microsoft.AspNet.OData.Interfaces;
diff --git a/src/Microsoft.AspNetCore.OData/Adapters/WebApiRequestHeaders.cs b/src/Microsoft.AspNetCore.OData/Adapters/WebApiRequestHeaders.cs
index 012703f271..2661183066 100644
--- a/src/Microsoft.AspNetCore.OData/Adapters/WebApiRequestHeaders.cs
+++ b/src/Microsoft.AspNetCore.OData/Adapters/WebApiRequestHeaders.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Linq;
diff --git a/src/Microsoft.AspNetCore.OData/Adapters/WebApiRequestMessage.cs b/src/Microsoft.AspNetCore.OData/Adapters/WebApiRequestMessage.cs
index 7e6e93d081..37ed871d57 100644
--- a/src/Microsoft.AspNetCore.OData/Adapters/WebApiRequestMessage.cs
+++ b/src/Microsoft.AspNetCore.OData/Adapters/WebApiRequestMessage.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNetCore.OData/Adapters/WebApiUrlHelper.cs b/src/Microsoft.AspNetCore.OData/Adapters/WebApiUrlHelper.cs
index 43618fffe6..9b84800ce0 100644
--- a/src/Microsoft.AspNetCore.OData/Adapters/WebApiUrlHelper.cs
+++ b/src/Microsoft.AspNetCore.OData/Adapters/WebApiUrlHelper.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNetCore.OData/Batch/ChangeSetRequestItem.cs b/src/Microsoft.AspNetCore.OData/Batch/ChangeSetRequestItem.cs
index e8becc8c57..09991f698b 100644
--- a/src/Microsoft.AspNetCore.OData/Batch/ChangeSetRequestItem.cs
+++ b/src/Microsoft.AspNetCore.OData/Batch/ChangeSetRequestItem.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Threading.Tasks;
@@ -68,4 +72,4 @@ public override async Task SendRequestAsync(RequestDeleg
return new ChangeSetResponseItem(responseContexts);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNetCore.OData/Batch/ChangeSetResponseItem.cs b/src/Microsoft.AspNetCore.OData/Batch/ChangeSetResponseItem.cs
index 0b4d1619d3..f607b9ac1f 100644
--- a/src/Microsoft.AspNetCore.OData/Batch/ChangeSetResponseItem.cs
+++ b/src/Microsoft.AspNetCore.OData/Batch/ChangeSetResponseItem.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Linq;
@@ -79,4 +83,4 @@ internal override bool IsResponseSuccessful()
return Contexts.All(c => c.Response.IsSuccessStatusCode());
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNetCore.OData/Batch/DefaultODataBatchHandler.cs b/src/Microsoft.AspNetCore.OData/Batch/DefaultODataBatchHandler.cs
index ec2821edd7..de7da25058 100644
--- a/src/Microsoft.AspNetCore.OData/Batch/DefaultODataBatchHandler.cs
+++ b/src/Microsoft.AspNetCore.OData/Batch/DefaultODataBatchHandler.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
@@ -134,4 +138,4 @@ public virtual async Task> ParseBatchRequestsAsync(
return requests;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNetCore.OData/Batch/HttpRequestExtensions.cs b/src/Microsoft.AspNetCore.OData/Batch/HttpRequestExtensions.cs
index e27e8828e7..e907ae500c 100644
--- a/src/Microsoft.AspNetCore.OData/Batch/HttpRequestExtensions.cs
+++ b/src/Microsoft.AspNetCore.OData/Batch/HttpRequestExtensions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.ComponentModel;
@@ -93,4 +97,4 @@ public static void CopyBatchRequestProperties(this HttpRequest subRequest, HttpR
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNetCore.OData/Batch/ODataBatchContent.cs b/src/Microsoft.AspNetCore.OData/Batch/ODataBatchContent.cs
index 0935925a30..571e055f41 100644
--- a/src/Microsoft.AspNetCore.OData/Batch/ODataBatchContent.cs
+++ b/src/Microsoft.AspNetCore.OData/Batch/ODataBatchContent.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
@@ -72,4 +76,4 @@ public Task SerializeToStreamAsync(Stream stream)
return WriteToResponseMessageAsync(responseMessage);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNetCore.OData/Batch/ODataBatchHandler.cs b/src/Microsoft.AspNetCore.OData/Batch/ODataBatchHandler.cs
index f02dd6b5b1..d1bd7f985c 100644
--- a/src/Microsoft.AspNetCore.OData/Batch/ODataBatchHandler.cs
+++ b/src/Microsoft.AspNetCore.OData/Batch/ODataBatchHandler.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
@@ -79,4 +83,4 @@ public virtual Uri GetBaseUri(HttpRequest request)
return request.GetODataBatchBaseUri(ODataRouteName, ODataRoute);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNetCore.OData/Batch/ODataBatchHttpRequestMessageExtensions.cs b/src/Microsoft.AspNetCore.OData/Batch/ODataBatchHttpRequestMessageExtensions.cs
index 874bbf445c..b5fa57bdf3 100644
--- a/src/Microsoft.AspNetCore.OData/Batch/ODataBatchHttpRequestMessageExtensions.cs
+++ b/src/Microsoft.AspNetCore.OData/Batch/ODataBatchHttpRequestMessageExtensions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNetCore.OData/Batch/ODataBatchMiddleware.cs b/src/Microsoft.AspNetCore.OData/Batch/ODataBatchMiddleware.cs
index 4e295fdd9e..7aa5323db7 100644
--- a/src/Microsoft.AspNetCore.OData/Batch/ODataBatchMiddleware.cs
+++ b/src/Microsoft.AspNetCore.OData/Batch/ODataBatchMiddleware.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Threading.Tasks;
diff --git a/src/Microsoft.AspNetCore.OData/Batch/ODataBatchPathMapping.cs b/src/Microsoft.AspNetCore.OData/Batch/ODataBatchPathMapping.cs
index 3beaf094e7..72b38caf66 100644
--- a/src/Microsoft.AspNetCore.OData/Batch/ODataBatchPathMapping.cs
+++ b/src/Microsoft.AspNetCore.OData/Batch/ODataBatchPathMapping.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNetCore.OData/Batch/ODataBatchReaderExtensions.cs b/src/Microsoft.AspNetCore.OData/Batch/ODataBatchReaderExtensions.cs
index e054e0fa57..4c12694a16 100644
--- a/src/Microsoft.AspNetCore.OData/Batch/ODataBatchReaderExtensions.cs
+++ b/src/Microsoft.AspNetCore.OData/Batch/ODataBatchReaderExtensions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
@@ -393,4 +397,4 @@ private static IEnumerable SplitPreferences(string preferences)
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNetCore.OData/Batch/ODataBatchRequestItem.cs b/src/Microsoft.AspNetCore.OData/Batch/ODataBatchRequestItem.cs
index 188788b41c..d895965bd4 100644
--- a/src/Microsoft.AspNetCore.OData/Batch/ODataBatchRequestItem.cs
+++ b/src/Microsoft.AspNetCore.OData/Batch/ODataBatchRequestItem.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
@@ -93,4 +97,4 @@ private static void AddLocationHeaderToMapping(
/// A .
public abstract Task SendRequestAsync(RequestDelegate handler);
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNetCore.OData/Batch/ODataBatchResponseItem.cs b/src/Microsoft.AspNetCore.OData/Batch/ODataBatchResponseItem.cs
index 09cec3f994..30da741d33 100644
--- a/src/Microsoft.AspNetCore.OData/Batch/ODataBatchResponseItem.cs
+++ b/src/Microsoft.AspNetCore.OData/Batch/ODataBatchResponseItem.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNetCore.OData/Batch/ODataBatchStream.cs b/src/Microsoft.AspNetCore.OData/Batch/ODataBatchStream.cs
index b6e2326058..43ef7f26b5 100644
--- a/src/Microsoft.AspNetCore.OData/Batch/ODataBatchStream.cs
+++ b/src/Microsoft.AspNetCore.OData/Batch/ODataBatchStream.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.IO;
using System.Threading.Tasks;
@@ -50,4 +54,4 @@ public override void Close()
{
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNetCore.OData/Batch/OperationRequestItem.cs b/src/Microsoft.AspNetCore.OData/Batch/OperationRequestItem.cs
index c5cc1262b8..525b7c33bf 100644
--- a/src/Microsoft.AspNetCore.OData/Batch/OperationRequestItem.cs
+++ b/src/Microsoft.AspNetCore.OData/Batch/OperationRequestItem.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Threading.Tasks;
using Microsoft.AspNet.OData.Common;
@@ -47,4 +51,4 @@ public override async Task SendRequestAsync(RequestDeleg
return new OperationResponseItem(Context);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNetCore.OData/Batch/OperationResponseItem.cs b/src/Microsoft.AspNetCore.OData/Batch/OperationResponseItem.cs
index 896a508ff0..335d30bb60 100644
--- a/src/Microsoft.AspNetCore.OData/Batch/OperationResponseItem.cs
+++ b/src/Microsoft.AspNetCore.OData/Batch/OperationResponseItem.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Threading.Tasks;
using Microsoft.AspNet.OData.Common;
@@ -56,4 +60,4 @@ internal override bool IsResponseSuccessful()
return Context.Response.IsSuccessStatusCode();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNetCore.OData/Batch/UnbufferedODataBatchHandler.cs b/src/Microsoft.AspNetCore.OData/Batch/UnbufferedODataBatchHandler.cs
index 3d08c775c6..4ff47b4043 100644
--- a/src/Microsoft.AspNetCore.OData/Batch/UnbufferedODataBatchHandler.cs
+++ b/src/Microsoft.AspNetCore.OData/Batch/UnbufferedODataBatchHandler.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
@@ -166,4 +170,4 @@ public virtual async Task ExecuteChangeSetAsync(ODataBat
return new ChangeSetResponseItem(changeSetResponse);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNetCore.OData/Builder/ODataConventionModelBuilder.cs b/src/Microsoft.AspNetCore.OData/Builder/ODataConventionModelBuilder.cs
index 1cb243cdc2..49e22c817d 100644
--- a/src/Microsoft.AspNetCore.OData/Builder/ODataConventionModelBuilder.cs
+++ b/src/Microsoft.AspNetCore.OData/Builder/ODataConventionModelBuilder.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Adapters;
diff --git a/src/Microsoft.AspNetCore.OData/ETagMessageHandler.cs b/src/Microsoft.AspNetCore.OData/ETagMessageHandler.cs
index 66cac21f03..c05dd454ef 100644
--- a/src/Microsoft.AspNetCore.OData/ETagMessageHandler.cs
+++ b/src/Microsoft.AspNetCore.OData/ETagMessageHandler.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Net.Http.Headers;
diff --git a/src/Microsoft.AspNetCore.OData/EnableNestedPathsAttribute.cs b/src/Microsoft.AspNetCore.OData/EnableNestedPathsAttribute.cs
new file mode 100644
index 0000000000..437966d0e7
--- /dev/null
+++ b/src/Microsoft.AspNetCore.OData/EnableNestedPathsAttribute.cs
@@ -0,0 +1,147 @@
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
+
+using System;
+using System.Linq;
+using System.Reflection;
+using Microsoft.AspNet.OData.Adapters;
+using Microsoft.AspNet.OData.Common;
+using Microsoft.AspNet.OData.Extensions;
+using Microsoft.AspNet.OData.Query;
+using Microsoft.AspNet.OData.Routing;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc.Controllers;
+using Microsoft.AspNetCore.Mvc.Filters;
+using Microsoft.OData.Edm;
+
+namespace Microsoft.AspNet.OData
+{
+ ///
+ /// This class defines an attribute that can be applied to an action to allow handling
+ /// of arbitrarily nested paths. The result of the action should be an IQueryable
+ /// or SingleResult. The sequence of property and key accesses in the path will be
+ /// applied to the result of the action through query transformations.
+ ///
+ [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
+ public sealed class EnableNestedPathsAttribute : ActionFilterAttribute
+ {
+ ///
+ public EnableNestedPathsAttribute(): base()
+ {
+ // ensures this filter is executed before [EnableQuery] which has default order 0
+ // since the OnActionExecuted method is executed after the action,
+ // a filter with a lower order will be executed after a filter with a higher order
+ Order = 1;
+ }
+
+ ///
+ /// Transforms the result of the action based on the sequence of property accesses in the odata path
+ /// after the action is executed.
+ /// It first tries to retrieve the IQueryable from the
+ /// returning response message. It then uses the to transform
+ /// the query and sets the result back to the response message.
+ ///
+ /// The context related to this action, including the response message,
+ /// request message and HttpConfiguration etc.
+ public override void OnActionExecuted(ActionExecutedContext actionExecutedContext)
+ {
+ if (actionExecutedContext == null)
+ {
+ throw Error.ArgumentNull("actionExecutedContext");
+ }
+
+ HttpRequest request = actionExecutedContext.HttpContext.Request;
+ if (request == null)
+ {
+ throw Error.Argument("actionExecutedContext", SRResources.ActionExecutedContextMustHaveRequest);
+ }
+
+ ControllerActionDescriptor actionDescriptor = actionExecutedContext.ActionDescriptor as ControllerActionDescriptor;
+ if (actionDescriptor == null)
+ {
+ throw Error.Argument("actionExecutedContext", SRResources.ActionContextMustHaveDescriptor);
+ }
+
+ HttpResponse response = actionExecutedContext.HttpContext.Response;
+
+ ObjectResult responseContent = actionExecutedContext.Result as ObjectResult;
+ IQueryable result = responseContent.Value as IQueryable;
+ SingleResult singleResult = responseContent.Value as SingleResult;
+ if (singleResult != null)
+ {
+ // This could be a SingleResult, which has the property Queryable.
+ // But it could be a SingleResult() or SingleResult. Sort by number of parameters
+ // on the property and get the one with the most parameters.
+ PropertyInfo propInfo = singleResult.GetType().GetProperties()
+ .Where(p => p.Name.Equals("Queryable"))
+ .OrderByDescending(p => p.GetIndexParameters().Count())
+ .FirstOrDefault();
+
+ result = propInfo.GetValue(singleResult) as IQueryable;
+ }
+
+ if (result != null)
+ {
+ ODataPath path = actionExecutedContext.HttpContext.ODataFeature().Path;
+ IEdmModel model = actionExecutedContext.HttpContext.Request.GetModel();
+
+ var queryBuilder = new ODataPathQueryBuilder(result, path);
+ ODataPathQueryResult transformedResult = queryBuilder.BuildQuery();
+
+ if (transformedResult == null)
+ {
+ actionExecutedContext.Result = new NotFoundObjectResult(null);
+ }
+ else if (path.EdmType.TypeKind == EdmTypeKind.Collection || transformedResult.HasCountSegment)
+ {
+ responseContent.Value = transformedResult.Result;
+ }
+ else
+ {
+ Type elementType = transformedResult.Result.ElementType;
+
+ // If we return the IQueryable as the result, then the response will be returned as a collection
+ // so we have to return a single result. We can either return the materialized single result using SingleOrDefault,
+ // which will run the query against the underlying data source. Or we can wrap the IQueryable result with
+ // a SingleResult.
+ // If the action has [EnableQuery], then we return a SingleResult which allows query options to be
+ // applied to the IQueryable. If we returned the materialized object, then query options like $expand
+ // would return null because navigation properties are not fetched from relational databases by default.
+ // If the action does not have [EnableQuery], then we run the query using SingleOrDefault and return the
+ // actual object. If we returned a SingleResult in this case, we'd get an error because the serializer
+ // does not recognize it.
+ if (actionDescriptor.MethodInfo.GetCustomAttributes().Any())
+ {
+ // calls SingleResult.Create(IQueryable)
+ responseContent.Value = ExpressionHelpers.CreateSingleResult(transformedResult.Result, transformedResult.Result.ElementType);
+ }
+ else
+ {
+ try
+ {
+ object singleValue = QueryHelpers.SingleOrDefault(transformedResult.Result, new WebApiActionDescriptor(actionDescriptor));
+
+ if (singleValue == null)
+ {
+ actionExecutedContext.Result = new NotFoundObjectResult(null);
+ }
+ else
+ {
+ responseContent.Value = singleValue;
+ }
+ }
+ catch (NullReferenceException)
+ {
+ actionExecutedContext.Result = new NotFoundObjectResult(null);
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/src/Microsoft.AspNetCore.OData/EnableQueryAttribute.cs b/src/Microsoft.AspNetCore.OData/EnableQueryAttribute.cs
index c96e862503..480fc975d8 100644
--- a/src/Microsoft.AspNetCore.OData/EnableQueryAttribute.cs
+++ b/src/Microsoft.AspNetCore.OData/EnableQueryAttribute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
@@ -140,7 +144,7 @@ public override void OnActionExecuting(ActionExecutingContext context)
{
elementType = TypeHelper.GetImplementedIEnumerableType(returnType);
}
- else if(TypeHelper.IsGenericType(returnType) && returnType.GetGenericTypeDefinition() == typeof(Task<>))
+ else if (TypeHelper.IsGenericType(returnType) && returnType.GetGenericTypeDefinition() == typeof(Task<>))
{
elementType = returnType.GetGenericArguments().First();
}
@@ -228,46 +232,44 @@ public override void OnActionExecuted(ActionExecutedContext actionExecutedContex
{
// actionExecutedContext.Result might also indicate a status code that has not yet
// been applied to the result; make sure it's also successful.
- StatusCodeResult statusCodeResult = actionExecutedContext.Result as StatusCodeResult;
- if (statusCodeResult == null || IsSuccessStatusCode(statusCodeResult.StatusCode))
+ ObjectResult responseContent = actionExecutedContext.Result as ObjectResult;
+
+ if (responseContent != null && (responseContent.StatusCode == null || IsSuccessStatusCode(responseContent.StatusCode.Value)))
{
- ObjectResult responseContent = actionExecutedContext.Result as ObjectResult;
- if (responseContent != null)
+
+ //throw Error.Argument("actionExecutedContext", SRResources.QueryingRequiresObjectContent,
+ // actionExecutedContext.Result.GetType().FullName);
+
+ // Get collection from SingleResult.
+ IQueryable singleResultCollection = null;
+ SingleResult singleResult = responseContent.Value as SingleResult;
+ if (singleResult != null)
+ {
+ // This could be a SingleResult, which has the property Queryable.
+ // But it could be a SingleResult() or SingleResult. Sort by number of parameters
+ // on the property and get the one with the most parameters.
+ PropertyInfo propInfo = responseContent.Value.GetType().GetProperties()
+ .OrderBy(p => p.GetIndexParameters().Count())
+ .Where(p => p.Name.Equals("Queryable"))
+ .LastOrDefault();
+
+ singleResultCollection = propInfo.GetValue(singleResult) as IQueryable;
+ }
+
+ // Execution the action.
+ object queryResult = OnActionExecuted(
+ responseContent.Value,
+ singleResultCollection,
+ new WebApiActionDescriptor(actionDescriptor as ControllerActionDescriptor),
+ new WebApiRequestMessage(request),
+ (elementClrType) => GetModel(elementClrType, request, actionDescriptor),
+ (queryContext) => CreateAndValidateQueryOptions(request, queryContext),
+ (statusCode) => actionExecutedContext.Result = new StatusCodeResult((int)statusCode),
+ (statusCode, message, exception) => actionExecutedContext.Result = CreateBadRequestResult(message, exception));
+
+ if (queryResult != null)
{
- //throw Error.Argument("actionExecutedContext", SRResources.QueryingRequiresObjectContent,
- // actionExecutedContext.Result.GetType().FullName);
-
- // Get collection from SingleResult.
- IQueryable singleResultCollection = null;
- SingleResult singleResult = responseContent.Value as SingleResult;
- if (singleResult != null)
- {
- // This could be a SingleResult, which has the property Queryable.
- // But it could be a SingleResult() or SingleResult. Sort by number of parameters
- // on the property and get the one with the most parameters.
- PropertyInfo propInfo = responseContent.Value.GetType().GetProperties()
- .OrderBy(p => p.GetIndexParameters().Count())
- .Where(p => p.Name.Equals("Queryable"))
- .LastOrDefault();
-
- singleResultCollection = propInfo.GetValue(singleResult) as IQueryable;
- }
-
- // Execution the action.
- object queryResult = OnActionExecuted(
- responseContent.Value,
- singleResultCollection,
- new WebApiActionDescriptor(actionDescriptor as ControllerActionDescriptor),
- new WebApiRequestMessage(request),
- (elementClrType) => GetModel(elementClrType, request, actionDescriptor),
- (queryContext) => CreateAndValidateQueryOptions(request, queryContext),
- (statusCode) => actionExecutedContext.Result = new StatusCodeResult((int)statusCode),
- (statusCode, message, exception) => actionExecutedContext.Result = CreateBadRequestResult(message, exception));
-
- if (queryResult != null)
- {
- responseContent.Value = queryResult;
- }
+ responseContent.Value = queryResult;
}
}
}
@@ -436,4 +438,4 @@ private class RequestQueryData
public ODataQueryOptions ProcessedQueryOptions { get; set; }
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNetCore.OData/Extensions/ActionDescriptorExtensions.cs b/src/Microsoft.AspNetCore.OData/Extensions/ActionDescriptorExtensions.cs
index b89211fba1..1f1d8578d4 100644
--- a/src/Microsoft.AspNetCore.OData/Extensions/ActionDescriptorExtensions.cs
+++ b/src/Microsoft.AspNetCore.OData/Extensions/ActionDescriptorExtensions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.ComponentModel;
diff --git a/src/Microsoft.AspNetCore.OData/Extensions/Endpoint/ODataEndpointBuilderExtensions.cs b/src/Microsoft.AspNetCore.OData/Extensions/Endpoint/ODataEndpointBuilderExtensions.cs
index 9d2f36ccd1..9acb537884 100644
--- a/src/Microsoft.AspNetCore.OData/Extensions/Endpoint/ODataEndpointBuilderExtensions.cs
+++ b/src/Microsoft.AspNetCore.OData/Extensions/Endpoint/ODataEndpointBuilderExtensions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
#if !NETSTANDARD2_0
using System;
diff --git a/src/Microsoft.AspNetCore.OData/Extensions/Endpoint/ODataEndpointLinkGenerator.cs b/src/Microsoft.AspNetCore.OData/Extensions/Endpoint/ODataEndpointLinkGenerator.cs
index e05c0aff93..e0e2e7bf3b 100644
--- a/src/Microsoft.AspNetCore.OData/Extensions/Endpoint/ODataEndpointLinkGenerator.cs
+++ b/src/Microsoft.AspNetCore.OData/Extensions/Endpoint/ODataEndpointLinkGenerator.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
#if !NETSTANDARD2_0
using System;
diff --git a/src/Microsoft.AspNetCore.OData/Extensions/Endpoint/ODataEndpointPattern.cs b/src/Microsoft.AspNetCore.OData/Extensions/Endpoint/ODataEndpointPattern.cs
index ea992c216a..a91a4864b0 100644
--- a/src/Microsoft.AspNetCore.OData/Extensions/Endpoint/ODataEndpointPattern.cs
+++ b/src/Microsoft.AspNetCore.OData/Extensions/Endpoint/ODataEndpointPattern.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
#if !NETSTANDARD2_0
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNetCore.OData/Extensions/Endpoint/ODataEndpointRouteValueTransformer.cs b/src/Microsoft.AspNetCore.OData/Extensions/Endpoint/ODataEndpointRouteValueTransformer.cs
index e6a4c1b8eb..f83b886fb5 100644
--- a/src/Microsoft.AspNetCore.OData/Extensions/Endpoint/ODataEndpointRouteValueTransformer.cs
+++ b/src/Microsoft.AspNetCore.OData/Extensions/Endpoint/ODataEndpointRouteValueTransformer.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
#if !NETSTANDARD2_0
using System;
diff --git a/src/Microsoft.AspNetCore.OData/Extensions/Endpoint/ODataEndpointSelectorPolicy.cs b/src/Microsoft.AspNetCore.OData/Extensions/Endpoint/ODataEndpointSelectorPolicy.cs
index dd5d1a408b..430fe05fe5 100644
--- a/src/Microsoft.AspNetCore.OData/Extensions/Endpoint/ODataEndpointSelectorPolicy.cs
+++ b/src/Microsoft.AspNetCore.OData/Extensions/Endpoint/ODataEndpointSelectorPolicy.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
#if !NETSTANDARD2_0
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNetCore.OData/Extensions/HttpContextExtensions.cs b/src/Microsoft.AspNetCore.OData/Extensions/HttpContextExtensions.cs
index 573de8140d..82f9b2da2d 100644
--- a/src/Microsoft.AspNetCore.OData/Extensions/HttpContextExtensions.cs
+++ b/src/Microsoft.AspNetCore.OData/Extensions/HttpContextExtensions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Common;
using Microsoft.AspNet.OData.Formatter;
@@ -95,4 +99,4 @@ public static IETagHandler GetETagHandler(this HttpContext httpContext)
return httpContext.RequestServices.GetRequiredService();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNetCore.OData/Extensions/HttpRequestExtensions.cs b/src/Microsoft.AspNetCore.OData/Extensions/HttpRequestExtensions.cs
index 5127082ff8..2ebc3d8ff5 100644
--- a/src/Microsoft.AspNetCore.OData/Extensions/HttpRequestExtensions.cs
+++ b/src/Microsoft.AspNetCore.OData/Extensions/HttpRequestExtensions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
@@ -524,4 +528,4 @@ private static IServiceScope CreateRequestScope(this HttpRequest request, string
return scope;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNetCore.OData/Extensions/HttpResponseExtensions.cs b/src/Microsoft.AspNetCore.OData/Extensions/HttpResponseExtensions.cs
index 9993a959ef..2d15f19cb1 100644
--- a/src/Microsoft.AspNetCore.OData/Extensions/HttpResponseExtensions.cs
+++ b/src/Microsoft.AspNetCore.OData/Extensions/HttpResponseExtensions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNetCore.Http;
@@ -20,4 +24,4 @@ public static bool IsSuccessStatusCode(this HttpResponse response)
return response?.StatusCode >= 200 && response.StatusCode < 300;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNetCore.OData/Extensions/ODataApplicationBuilderExtensions.cs b/src/Microsoft.AspNetCore.OData/Extensions/ODataApplicationBuilderExtensions.cs
index c9f75ca3da..c1138ef8fa 100644
--- a/src/Microsoft.AspNetCore.OData/Extensions/ODataApplicationBuilderExtensions.cs
+++ b/src/Microsoft.AspNetCore.OData/Extensions/ODataApplicationBuilderExtensions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Batch;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNetCore.OData/Extensions/ODataRouteBuilderExtensions.cs b/src/Microsoft.AspNetCore.OData/Extensions/ODataRouteBuilderExtensions.cs
index fad53b0a37..8d84bcf30e 100644
--- a/src/Microsoft.AspNetCore.OData/Extensions/ODataRouteBuilderExtensions.cs
+++ b/src/Microsoft.AspNetCore.OData/Extensions/ODataRouteBuilderExtensions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNetCore.OData/Extensions/ODataServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.OData/Extensions/ODataServiceCollectionExtensions.cs
index 0fbad56a80..a69ce647c2 100644
--- a/src/Microsoft.AspNetCore.OData/Extensions/ODataServiceCollectionExtensions.cs
+++ b/src/Microsoft.AspNetCore.OData/Extensions/ODataServiceCollectionExtensions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Linq;
diff --git a/src/Microsoft.AspNetCore.OData/Extensions/ODataServiceProviderConfigExtenions.cs b/src/Microsoft.AspNetCore.OData/Extensions/ODataServiceProviderConfigExtenions.cs
index 605c5f76e6..7819a3f68d 100644
--- a/src/Microsoft.AspNetCore.OData/Extensions/ODataServiceProviderConfigExtenions.cs
+++ b/src/Microsoft.AspNetCore.OData/Extensions/ODataServiceProviderConfigExtenions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNetCore.OData/Extensions/SerializableErrorExtensions.cs b/src/Microsoft.AspNetCore.OData/Extensions/SerializableErrorExtensions.cs
index c23065518a..c0faab0d67 100644
--- a/src/Microsoft.AspNetCore.OData/Extensions/SerializableErrorExtensions.cs
+++ b/src/Microsoft.AspNetCore.OData/Extensions/SerializableErrorExtensions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNetCore.OData/Extensions/UrlHelperExtensions.cs b/src/Microsoft.AspNetCore.OData/Extensions/UrlHelperExtensions.cs
index 0c9790dbc4..e36aacdf33 100644
--- a/src/Microsoft.AspNetCore.OData/Extensions/UrlHelperExtensions.cs
+++ b/src/Microsoft.AspNetCore.OData/Extensions/UrlHelperExtensions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNetCore.OData/Formatter/Deserialization/DefaultODataDeserializerProvider.cs b/src/Microsoft.AspNetCore.OData/Formatter/Deserialization/DefaultODataDeserializerProvider.cs
index 82183b6658..1ade18b575 100644
--- a/src/Microsoft.AspNetCore.OData/Formatter/Deserialization/DefaultODataDeserializerProvider.cs
+++ b/src/Microsoft.AspNetCore.OData/Formatter/Deserialization/DefaultODataDeserializerProvider.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Extensions;
diff --git a/src/Microsoft.AspNetCore.OData/Formatter/Deserialization/ODataDeserializerContext.cs b/src/Microsoft.AspNetCore.OData/Formatter/Deserialization/ODataDeserializerContext.cs
index 0106cfba72..0b89fbebd9 100644
--- a/src/Microsoft.AspNetCore.OData/Formatter/Deserialization/ODataDeserializerContext.cs
+++ b/src/Microsoft.AspNetCore.OData/Formatter/Deserialization/ODataDeserializerContext.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Adapters;
using Microsoft.AspNet.OData.Extensions;
diff --git a/src/Microsoft.AspNetCore.OData/Formatter/Deserialization/ODataDeserializerProvider.cs b/src/Microsoft.AspNetCore.OData/Formatter/Deserialization/ODataDeserializerProvider.cs
index 1fcb9202cc..f6dd6b5642 100644
--- a/src/Microsoft.AspNetCore.OData/Formatter/Deserialization/ODataDeserializerProvider.cs
+++ b/src/Microsoft.AspNetCore.OData/Formatter/Deserialization/ODataDeserializerProvider.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNetCore.Http;
diff --git a/src/Microsoft.AspNetCore.OData/Formatter/IMediaTypeMappingCollection.cs b/src/Microsoft.AspNetCore.OData/Formatter/IMediaTypeMappingCollection.cs
index 736c9667f2..a84650cc47 100644
--- a/src/Microsoft.AspNetCore.OData/Formatter/IMediaTypeMappingCollection.cs
+++ b/src/Microsoft.AspNetCore.OData/Formatter/IMediaTypeMappingCollection.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNetCore.OData/Formatter/MediaTypeMapping.cs b/src/Microsoft.AspNetCore.OData/Formatter/MediaTypeMapping.cs
index 9fd2631cad..389df22194 100644
--- a/src/Microsoft.AspNetCore.OData/Formatter/MediaTypeMapping.cs
+++ b/src/Microsoft.AspNetCore.OData/Formatter/MediaTypeMapping.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Net.Http.Headers;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNetCore.OData/Formatter/ODataCountMediaTypeMapping.cs b/src/Microsoft.AspNetCore.OData/Formatter/ODataCountMediaTypeMapping.cs
index b0e7768113..d9d24926a2 100644
--- a/src/Microsoft.AspNetCore.OData/Formatter/ODataCountMediaTypeMapping.cs
+++ b/src/Microsoft.AspNetCore.OData/Formatter/ODataCountMediaTypeMapping.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Common;
using Microsoft.AspNet.OData.Extensions;
diff --git a/src/Microsoft.AspNetCore.OData/Formatter/ODataInputFormatter.cs b/src/Microsoft.AspNetCore.OData/Formatter/ODataInputFormatter.cs
index a1c45332dd..2418186209 100644
--- a/src/Microsoft.AspNetCore.OData/Formatter/ODataInputFormatter.cs
+++ b/src/Microsoft.AspNetCore.OData/Formatter/ODataInputFormatter.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
@@ -238,4 +242,4 @@ internal static ODataVersion GetODataResponseVersion(HttpRequest request)
ODataVersionConstraint.DefaultODataVersion;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNetCore.OData/Formatter/ODataInputFormatterFactory.cs b/src/Microsoft.AspNetCore.OData/Formatter/ODataInputFormatterFactory.cs
index 2b1a09c8f8..2a639a4040 100644
--- a/src/Microsoft.AspNetCore.OData/Formatter/ODataInputFormatterFactory.cs
+++ b/src/Microsoft.AspNetCore.OData/Formatter/ODataInputFormatterFactory.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Text;
diff --git a/src/Microsoft.AspNetCore.OData/Formatter/ODataModelBinder.cs b/src/Microsoft.AspNetCore.OData/Formatter/ODataModelBinder.cs
index 15936f7925..8d2dcdc646 100644
--- a/src/Microsoft.AspNetCore.OData/Formatter/ODataModelBinder.cs
+++ b/src/Microsoft.AspNetCore.OData/Formatter/ODataModelBinder.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.ComponentModel.DataAnnotations;
diff --git a/src/Microsoft.AspNetCore.OData/Formatter/ODataOutputFormatter.cs b/src/Microsoft.AspNetCore.OData/Formatter/ODataOutputFormatter.cs
index 84e608ada5..b427bebb71 100644
--- a/src/Microsoft.AspNetCore.OData/Formatter/ODataOutputFormatter.cs
+++ b/src/Microsoft.AspNetCore.OData/Formatter/ODataOutputFormatter.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
@@ -473,4 +477,4 @@ public override string ToString()
return this.stream.ToString();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNetCore.OData/Formatter/ODataOutputFormatterFactory.cs b/src/Microsoft.AspNetCore.OData/Formatter/ODataOutputFormatterFactory.cs
index 8b15b58b04..af9bb037d9 100644
--- a/src/Microsoft.AspNetCore.OData/Formatter/ODataOutputFormatterFactory.cs
+++ b/src/Microsoft.AspNetCore.OData/Formatter/ODataOutputFormatterFactory.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Text;
diff --git a/src/Microsoft.AspNetCore.OData/Formatter/ODataRawValueMediaTypeMapping.cs b/src/Microsoft.AspNetCore.OData/Formatter/ODataRawValueMediaTypeMapping.cs
index 71ce897bc5..c402048397 100644
--- a/src/Microsoft.AspNetCore.OData/Formatter/ODataRawValueMediaTypeMapping.cs
+++ b/src/Microsoft.AspNetCore.OData/Formatter/ODataRawValueMediaTypeMapping.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Common;
using Microsoft.AspNet.OData.Extensions;
diff --git a/src/Microsoft.AspNetCore.OData/Formatter/ODataStreamMediaTypeMapping.cs b/src/Microsoft.AspNetCore.OData/Formatter/ODataStreamMediaTypeMapping.cs
index ed6cb77e25..96d2326d78 100644
--- a/src/Microsoft.AspNetCore.OData/Formatter/ODataStreamMediaTypeMapping.cs
+++ b/src/Microsoft.AspNetCore.OData/Formatter/ODataStreamMediaTypeMapping.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Common;
using Microsoft.AspNet.OData.Extensions;
diff --git a/src/Microsoft.AspNetCore.OData/Formatter/QueryStringMediaTypeMapping.cs b/src/Microsoft.AspNetCore.OData/Formatter/QueryStringMediaTypeMapping.cs
index dd4bc13a97..e316ce953a 100644
--- a/src/Microsoft.AspNetCore.OData/Formatter/QueryStringMediaTypeMapping.cs
+++ b/src/Microsoft.AspNetCore.OData/Formatter/QueryStringMediaTypeMapping.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Linq;
diff --git a/src/Microsoft.AspNetCore.OData/Formatter/Serialization/DefaultODataSerializerProvider.cs b/src/Microsoft.AspNetCore.OData/Formatter/Serialization/DefaultODataSerializerProvider.cs
index d17afbad1e..2877dc4d76 100644
--- a/src/Microsoft.AspNetCore.OData/Formatter/Serialization/DefaultODataSerializerProvider.cs
+++ b/src/Microsoft.AspNetCore.OData/Formatter/Serialization/DefaultODataSerializerProvider.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Extensions;
diff --git a/src/Microsoft.AspNetCore.OData/Formatter/Serialization/ODataErrorSerializer.cs b/src/Microsoft.AspNetCore.OData/Formatter/Serialization/ODataErrorSerializer.cs
index 1fae777f30..707b507b12 100644
--- a/src/Microsoft.AspNetCore.OData/Formatter/Serialization/ODataErrorSerializer.cs
+++ b/src/Microsoft.AspNetCore.OData/Formatter/Serialization/ODataErrorSerializer.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Extensions;
using Microsoft.AspNetCore.Mvc;
diff --git a/src/Microsoft.AspNetCore.OData/Formatter/Serialization/ODataSerializerContext.cs b/src/Microsoft.AspNetCore.OData/Formatter/Serialization/ODataSerializerContext.cs
index 21bf0e6209..4aece06197 100644
--- a/src/Microsoft.AspNetCore.OData/Formatter/Serialization/ODataSerializerContext.cs
+++ b/src/Microsoft.AspNetCore.OData/Formatter/Serialization/ODataSerializerContext.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Adapters;
using Microsoft.AspNet.OData.Extensions;
diff --git a/src/Microsoft.AspNetCore.OData/Formatter/Serialization/ODataSerializerProvider.cs b/src/Microsoft.AspNetCore.OData/Formatter/Serialization/ODataSerializerProvider.cs
index 4047ad996e..5a27f59623 100644
--- a/src/Microsoft.AspNetCore.OData/Formatter/Serialization/ODataSerializerProvider.cs
+++ b/src/Microsoft.AspNetCore.OData/Formatter/Serialization/ODataSerializerProvider.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNetCore.Http;
diff --git a/src/Microsoft.AspNetCore.OData/FromODataUriAttribute.cs b/src/Microsoft.AspNetCore.OData/FromODataUriAttribute.cs
index 664f9b9a23..69feb02b92 100644
--- a/src/Microsoft.AspNetCore.OData/FromODataUriAttribute.cs
+++ b/src/Microsoft.AspNetCore.OData/FromODataUriAttribute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Formatter;
diff --git a/src/Microsoft.AspNetCore.OData/GetNextPageHelper.cs b/src/Microsoft.AspNetCore.OData/GetNextPageHelper.cs
index 4520b25a9d..aa1b017278 100644
--- a/src/Microsoft.AspNetCore.OData/GetNextPageHelper.cs
+++ b/src/Microsoft.AspNetCore.OData/GetNextPageHelper.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNetCore.OData/HttpRequestScope.cs b/src/Microsoft.AspNetCore.OData/HttpRequestScope.cs
index 85b1ca8709..a61a520620 100644
--- a/src/Microsoft.AspNetCore.OData/HttpRequestScope.cs
+++ b/src/Microsoft.AspNetCore.OData/HttpRequestScope.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNetCore.Http;
diff --git a/src/Microsoft.AspNetCore.OData/Interfaces/IODataBatchFeature.cs b/src/Microsoft.AspNetCore.OData/Interfaces/IODataBatchFeature.cs
index caea855716..bec8e93085 100644
--- a/src/Microsoft.AspNetCore.OData/Interfaces/IODataBatchFeature.cs
+++ b/src/Microsoft.AspNetCore.OData/Interfaces/IODataBatchFeature.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNetCore.OData/Interfaces/IODataCoreBuilder.cs b/src/Microsoft.AspNetCore.OData/Interfaces/IODataCoreBuilder.cs
index 46a840b265..eac955f25f 100644
--- a/src/Microsoft.AspNetCore.OData/Interfaces/IODataCoreBuilder.cs
+++ b/src/Microsoft.AspNetCore.OData/Interfaces/IODataCoreBuilder.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.Extensions.DependencyInjection;
diff --git a/src/Microsoft.AspNetCore.OData/Interfaces/IODataFeature.cs b/src/Microsoft.AspNetCore.OData/Interfaces/IODataFeature.cs
index 801a17ad72..3d4e00ea0f 100644
--- a/src/Microsoft.AspNetCore.OData/Interfaces/IODataFeature.cs
+++ b/src/Microsoft.AspNetCore.OData/Interfaces/IODataFeature.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNetCore.OData/Microsoft.AspNetCore.OData.Nightly.Release.nuspec b/src/Microsoft.AspNetCore.OData/Microsoft.AspNetCore.OData.Nightly.nuspec
similarity index 83%
rename from src/Microsoft.AspNetCore.OData/Microsoft.AspNetCore.OData.Nightly.Release.nuspec
rename to src/Microsoft.AspNetCore.OData/Microsoft.AspNetCore.OData.Nightly.nuspec
index 9432a268a1..8d390167c5 100644
--- a/src/Microsoft.AspNetCore.OData/Microsoft.AspNetCore.OData.Nightly.Release.nuspec
+++ b/src/Microsoft.AspNetCore.OData/Microsoft.AspNetCore.OData.Nightly.nuspec
@@ -3,17 +3,18 @@
Microsoft.AspNetCore.OData
Microsoft ASP.NET Core 2.0 and 3.x for OData v4.0
- $VersionFullSemantic$-Nightly$NightlyBuildVersion$
- Microsoft
- © Microsoft Corporation. All rights reserved.
+ $VersionNuGetSemantic$-Nightly$NightlyBuildVersion$
+ OData (.NET Foundation)
+ © .NET Foundation and Contributors. All rights reserved.
This package contains everything you need to create OData v4.0 endpoints using ASP.NET Core MVC and to support OData query syntax for your web APIs.
This package contains everything you need to create OData v4.0 endpoints using ASP.NET Core MVC.
en-US
http://odata.github.io
- https://raw.githubusercontent.com/OData/WebApi/master/License.txt
+ MIT
true
Microsoft AspNetCore WebApi OData
- http://static.tumblr.com/hgchgxz/9ualgdf98/icon.png
+ images\odata.png
+
@@ -35,5 +36,6 @@
+
\ No newline at end of file
diff --git a/src/Microsoft.AspNetCore.OData/Microsoft.AspNetCore.OData.Release.nuspec b/src/Microsoft.AspNetCore.OData/Microsoft.AspNetCore.OData.Release.nuspec
index 9319501215..d7c2195ec5 100644
--- a/src/Microsoft.AspNetCore.OData/Microsoft.AspNetCore.OData.Release.nuspec
+++ b/src/Microsoft.AspNetCore.OData/Microsoft.AspNetCore.OData.Release.nuspec
@@ -4,17 +4,18 @@
Microsoft.AspNetCore.OData
Microsoft ASP.NET Core 2.0 and 3.x for OData v4.0
$VersionNuGetSemantic$
- Microsoft
- © Microsoft Corporation. All rights reserved.
+ OData (.NET Foundation)
+ © .NET Foundation and Contributors. All rights reserved.
This package contains everything you need to create OData v4.0 endpoints using ASP.NET Core MVC and to support OData query syntax for your web APIs.
This package contains everything you need to create OData v4.0 endpoints using ASP.NET Core MVC.
https://docs.microsoft.com/en-us/odata/changelog/webapi-7x
en-US
http://odata.github.io
- https://raw.githubusercontent.com/OData/WebApi/master/License.txt
+ MIT
true
Microsoft AspNetCore WebApi OData
- http://static.tumblr.com/hgchgxz/9ualgdf98/icon.png
+ images\odata.png
+
@@ -36,5 +37,6 @@
+
\ No newline at end of file
diff --git a/src/Microsoft.AspNetCore.OData/Microsoft.AspNetCore.OData.csproj b/src/Microsoft.AspNetCore.OData/Microsoft.AspNetCore.OData.csproj
index d022b17221..bc5948571b 100644
--- a/src/Microsoft.AspNetCore.OData/Microsoft.AspNetCore.OData.csproj
+++ b/src/Microsoft.AspNetCore.OData/Microsoft.AspNetCore.OData.csproj
@@ -41,9 +41,9 @@
-
-
-
+
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
@@ -80,4 +80,15 @@
SRResources.resx
+
+
+ ProductRoot=$(ProductBinPath);VersionNuGetSemantic=$(VersionNuGetSemantic)
+ $(NuspecProperties);NightlyBuildVersion=$(NightlyBuildVersion)
+ $(NuspecProperties);SourcesRoot=$(RootDir)
+ $(NuspecProperties);AspNetCorePackageDependency=$(AspNetCorePackageDependency)
+ $(NuspecProperties);DependencyInjection2PackageDependency=$(DependencyInjection2PackageDependency)
+ $(NuspecProperties);ODataLibPackageDependency=$(ODataLibPackageDependency)
+ $(NuspecProperties);NewtonsoftJsonPackageDependency=$(NewtonsoftJsonPackageDependency)
+
+
diff --git a/src/Microsoft.AspNetCore.OData/NonValidatingParameterBindingAttribute.cs b/src/Microsoft.AspNetCore.OData/NonValidatingParameterBindingAttribute.cs
index a72736d1fb..02148cc867 100644
--- a/src/Microsoft.AspNetCore.OData/NonValidatingParameterBindingAttribute.cs
+++ b/src/Microsoft.AspNetCore.OData/NonValidatingParameterBindingAttribute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
diff --git a/src/Microsoft.AspNetCore.OData/ODataBatchFeature.cs b/src/Microsoft.AspNetCore.OData/ODataBatchFeature.cs
index 215b3057b8..3cb4d4f090 100644
--- a/src/Microsoft.AspNetCore.OData/ODataBatchFeature.cs
+++ b/src/Microsoft.AspNetCore.OData/ODataBatchFeature.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNetCore.OData/ODataController.cs b/src/Microsoft.AspNetCore.OData/ODataController.cs
index c59374c8c6..81f474a7c4 100644
--- a/src/Microsoft.AspNetCore.OData/ODataController.cs
+++ b/src/Microsoft.AspNetCore.OData/ODataController.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Common;
using Microsoft.AspNet.OData.Results;
diff --git a/src/Microsoft.AspNetCore.OData/ODataFeature.cs b/src/Microsoft.AspNetCore.OData/ODataFeature.cs
index 225389920b..7fb2add0f9 100644
--- a/src/Microsoft.AspNetCore.OData/ODataFeature.cs
+++ b/src/Microsoft.AspNetCore.OData/ODataFeature.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNetCore.OData/ODataFormattingAttribute.cs b/src/Microsoft.AspNetCore.OData/ODataFormattingAttribute.cs
index 2e4dedf9a1..abe0042cb2 100644
--- a/src/Microsoft.AspNetCore.OData/ODataFormattingAttribute.cs
+++ b/src/Microsoft.AspNetCore.OData/ODataFormattingAttribute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Diagnostics.CodeAnalysis;
diff --git a/src/Microsoft.AspNetCore.OData/ODataMessageWrapperHelper.cs b/src/Microsoft.AspNetCore.OData/ODataMessageWrapperHelper.cs
index 5b9c2b5dba..58a45abd25 100644
--- a/src/Microsoft.AspNetCore.OData/ODataMessageWrapperHelper.cs
+++ b/src/Microsoft.AspNetCore.OData/ODataMessageWrapperHelper.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNetCore.OData/ODataNullValueMessageHandler.cs b/src/Microsoft.AspNetCore.OData/ODataNullValueMessageHandler.cs
index 6cfacdc184..1319b25565 100644
--- a/src/Microsoft.AspNetCore.OData/ODataNullValueMessageHandler.cs
+++ b/src/Microsoft.AspNetCore.OData/ODataNullValueMessageHandler.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Net;
using System.Net.Http;
diff --git a/src/Microsoft.AspNetCore.OData/ODataOptions.cs b/src/Microsoft.AspNetCore.OData/ODataOptions.cs
index ba8f5508d8..2d9d2467db 100644
--- a/src/Microsoft.AspNetCore.OData/ODataOptions.cs
+++ b/src/Microsoft.AspNetCore.OData/ODataOptions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.OData;
diff --git a/src/Microsoft.AspNetCore.OData/ODataQueryParameterBindingAttribute.cs b/src/Microsoft.AspNetCore.OData/ODataQueryParameterBindingAttribute.cs
index 7654037921..f0afb267c4 100644
--- a/src/Microsoft.AspNetCore.OData/ODataQueryParameterBindingAttribute.cs
+++ b/src/Microsoft.AspNetCore.OData/ODataQueryParameterBindingAttribute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Diagnostics.CodeAnalysis;
diff --git a/src/Microsoft.AspNetCore.OData/ODataRoutingAttribute.cs b/src/Microsoft.AspNetCore.OData/ODataRoutingAttribute.cs
index d2de8401f8..e9fefdc1b4 100644
--- a/src/Microsoft.AspNetCore.OData/ODataRoutingAttribute.cs
+++ b/src/Microsoft.AspNetCore.OData/ODataRoutingAttribute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
@@ -13,4 +17,4 @@ public sealed class ODataRoutingAttribute : Attribute
{
// This class is not needed; Routing is injected in ODataServiceCollectionExtensions::AddOdata()
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNetCore.OData/ODataServiceBuilder.cs b/src/Microsoft.AspNetCore.OData/ODataServiceBuilder.cs
index 641b28924f..a6ca174165 100644
--- a/src/Microsoft.AspNetCore.OData/ODataServiceBuilder.cs
+++ b/src/Microsoft.AspNetCore.OData/ODataServiceBuilder.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Common;
using Microsoft.AspNet.OData.Interfaces;
diff --git a/src/Microsoft.AspNetCore.OData/ODataValueProviderFactory.cs b/src/Microsoft.AspNetCore.OData/ODataValueProviderFactory.cs
index 3c6c528d15..6d058d702d 100644
--- a/src/Microsoft.AspNetCore.OData/ODataValueProviderFactory.cs
+++ b/src/Microsoft.AspNetCore.OData/ODataValueProviderFactory.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNetCore.OData/PerRouteContainer.cs b/src/Microsoft.AspNetCore.OData/PerRouteContainer.cs
index c6930cad13..6b0f9d53f2 100644
--- a/src/Microsoft.AspNetCore.OData/PerRouteContainer.cs
+++ b/src/Microsoft.AspNetCore.OData/PerRouteContainer.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Concurrent;
diff --git a/src/Microsoft.AspNetCore.OData/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.OData/Properties/AssemblyInfo.cs
index 70c522383d..e09883cfac 100644
--- a/src/Microsoft.AspNetCore.OData/Properties/AssemblyInfo.cs
+++ b/src/Microsoft.AspNetCore.OData/Properties/AssemblyInfo.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Reflection;
using System.Runtime.CompilerServices;
@@ -7,4 +11,4 @@
[assembly: AssemblyTitle("Microsoft.AspNetCore.OData")]
[assembly: AssemblyDescription("")]
-[assembly: InternalsVisibleTo("Microsoft.AspNetCore.OData.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
\ No newline at end of file
+[assembly: InternalsVisibleTo("Microsoft.AspNetCore.OData.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
diff --git a/src/Microsoft.AspNetCore.OData/Query/ODataQueryOptions.cs b/src/Microsoft.AspNetCore.OData/Query/ODataQueryOptions.cs
index bb23365a9a..7d4fbbd1b5 100644
--- a/src/Microsoft.AspNetCore.OData/Query/ODataQueryOptions.cs
+++ b/src/Microsoft.AspNetCore.OData/Query/ODataQueryOptions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Diagnostics.Contracts;
using Microsoft.AspNet.OData.Adapters;
diff --git a/src/Microsoft.AspNetCore.OData/Query/ODataQueryOptionsOfTEntity.cs b/src/Microsoft.AspNetCore.OData/Query/ODataQueryOptionsOfTEntity.cs
index b08648058a..2f64deb51a 100644
--- a/src/Microsoft.AspNetCore.OData/Query/ODataQueryOptionsOfTEntity.cs
+++ b/src/Microsoft.AspNetCore.OData/Query/ODataQueryOptionsOfTEntity.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Common;
using Microsoft.AspNetCore.Http;
diff --git a/src/Microsoft.AspNetCore.OData/Query/PlainTextODataQueryOptionsParser.cs b/src/Microsoft.AspNetCore.OData/Query/PlainTextODataQueryOptionsParser.cs
index 7485d23b9f..368c1a238f 100644
--- a/src/Microsoft.AspNetCore.OData/Query/PlainTextODataQueryOptionsParser.cs
+++ b/src/Microsoft.AspNetCore.OData/Query/PlainTextODataQueryOptionsParser.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNetCore.OData/Query/QueryFilterProvider.cs b/src/Microsoft.AspNetCore.OData/Query/QueryFilterProvider.cs
index 0d48649c55..ed63017721 100644
--- a/src/Microsoft.AspNetCore.OData/Query/QueryFilterProvider.cs
+++ b/src/Microsoft.AspNetCore.OData/Query/QueryFilterProvider.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Linq;
diff --git a/src/Microsoft.AspNetCore.OData/ResourceContext.cs b/src/Microsoft.AspNetCore.OData/ResourceContext.cs
index d54d72a6a4..223c7a3dd2 100644
--- a/src/Microsoft.AspNetCore.OData/ResourceContext.cs
+++ b/src/Microsoft.AspNetCore.OData/ResourceContext.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNetCore.Http;
diff --git a/src/Microsoft.AspNetCore.OData/ResourceSetContext.cs b/src/Microsoft.AspNetCore.OData/ResourceSetContext.cs
index d7a99133c1..f5163301d2 100644
--- a/src/Microsoft.AspNetCore.OData/ResourceSetContext.cs
+++ b/src/Microsoft.AspNetCore.OData/ResourceSetContext.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections;
using Microsoft.AspNet.OData.Adapters;
diff --git a/src/Microsoft.AspNetCore.OData/Results/BadRequestODataResult.cs b/src/Microsoft.AspNetCore.OData/Results/BadRequestODataResult.cs
index 592760c48e..9f6fee3eb0 100644
--- a/src/Microsoft.AspNetCore.OData/Results/BadRequestODataResult.cs
+++ b/src/Microsoft.AspNetCore.OData/Results/BadRequestODataResult.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
diff --git a/src/Microsoft.AspNetCore.OData/Results/ConflictODataResult.cs b/src/Microsoft.AspNetCore.OData/Results/ConflictODataResult.cs
index 83455aa313..330a58b6cb 100644
--- a/src/Microsoft.AspNetCore.OData/Results/ConflictODataResult.cs
+++ b/src/Microsoft.AspNetCore.OData/Results/ConflictODataResult.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
#if !NETSTANDARD2_0
using System.Threading.Tasks;
diff --git a/src/Microsoft.AspNetCore.OData/Results/CreatedODataResult.cs b/src/Microsoft.AspNetCore.OData/Results/CreatedODataResult.cs
index 6f6852858a..683d587405 100644
--- a/src/Microsoft.AspNetCore.OData/Results/CreatedODataResult.cs
+++ b/src/Microsoft.AspNetCore.OData/Results/CreatedODataResult.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Net;
diff --git a/src/Microsoft.AspNetCore.OData/Results/IODataErrorResult.cs b/src/Microsoft.AspNetCore.OData/Results/IODataErrorResult.cs
index 17c42a59b1..75a5783137 100644
--- a/src/Microsoft.AspNetCore.OData/Results/IODataErrorResult.cs
+++ b/src/Microsoft.AspNetCore.OData/Results/IODataErrorResult.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.OData;
diff --git a/src/Microsoft.AspNetCore.OData/Results/NotFoundODataResult.cs b/src/Microsoft.AspNetCore.OData/Results/NotFoundODataResult.cs
index d3634c74d1..666455df53 100644
--- a/src/Microsoft.AspNetCore.OData/Results/NotFoundODataResult.cs
+++ b/src/Microsoft.AspNetCore.OData/Results/NotFoundODataResult.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
diff --git a/src/Microsoft.AspNetCore.OData/Results/ODataErrorResult.cs b/src/Microsoft.AspNetCore.OData/Results/ODataErrorResult.cs
index 938866689e..40fb919227 100644
--- a/src/Microsoft.AspNetCore.OData/Results/ODataErrorResult.cs
+++ b/src/Microsoft.AspNetCore.OData/Results/ODataErrorResult.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Threading.Tasks;
diff --git a/src/Microsoft.AspNetCore.OData/Results/ResultHelpers.cs b/src/Microsoft.AspNetCore.OData/Results/ResultHelpers.cs
index f337f2b00c..18ba2cf19a 100644
--- a/src/Microsoft.AspNetCore.OData/Results/ResultHelpers.cs
+++ b/src/Microsoft.AspNetCore.OData/Results/ResultHelpers.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Diagnostics.Contracts;
diff --git a/src/Microsoft.AspNetCore.OData/Results/UnauthorizedODataResult.cs b/src/Microsoft.AspNetCore.OData/Results/UnauthorizedODataResult.cs
index cfa7c1706a..f7dc424249 100644
--- a/src/Microsoft.AspNetCore.OData/Results/UnauthorizedODataResult.cs
+++ b/src/Microsoft.AspNetCore.OData/Results/UnauthorizedODataResult.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
diff --git a/src/Microsoft.AspNetCore.OData/Results/UnprocessableEntityODataResult .cs b/src/Microsoft.AspNetCore.OData/Results/UnprocessableEntityODataResult .cs
index 5c3213ec55..a8b1089f84 100644
--- a/src/Microsoft.AspNetCore.OData/Results/UnprocessableEntityODataResult .cs
+++ b/src/Microsoft.AspNetCore.OData/Results/UnprocessableEntityODataResult .cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
#if !NETSTANDARD2_0
using System.Threading.Tasks;
diff --git a/src/Microsoft.AspNetCore.OData/Results/UpdatedODataResult.cs b/src/Microsoft.AspNetCore.OData/Results/UpdatedODataResult.cs
index 6019e33a99..3efdbcc8f7 100644
--- a/src/Microsoft.AspNetCore.OData/Results/UpdatedODataResult.cs
+++ b/src/Microsoft.AspNetCore.OData/Results/UpdatedODataResult.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Net;
using System.Threading.Tasks;
diff --git a/src/Microsoft.AspNetCore.OData/Routing/Conventions/ActionRoutingConvention.cs b/src/Microsoft.AspNetCore.OData/Routing/Conventions/ActionRoutingConvention.cs
index b422754d3c..053c50890f 100644
--- a/src/Microsoft.AspNetCore.OData/Routing/Conventions/ActionRoutingConvention.cs
+++ b/src/Microsoft.AspNetCore.OData/Routing/Conventions/ActionRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using Microsoft.AspNet.OData.Adapters;
diff --git a/src/Microsoft.AspNetCore.OData/Routing/Conventions/AttributeRoutingConvention.cs b/src/Microsoft.AspNetCore.OData/Routing/Conventions/AttributeRoutingConvention.cs
index e2476ff993..2bcb8df382 100644
--- a/src/Microsoft.AspNetCore.OData/Routing/Conventions/AttributeRoutingConvention.cs
+++ b/src/Microsoft.AspNetCore.OData/Routing/Conventions/AttributeRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNetCore.OData/Routing/Conventions/DynamicPropertyRoutingConvention.cs b/src/Microsoft.AspNetCore.OData/Routing/Conventions/DynamicPropertyRoutingConvention.cs
index f280ad1e76..95db9d2d5c 100644
--- a/src/Microsoft.AspNetCore.OData/Routing/Conventions/DynamicPropertyRoutingConvention.cs
+++ b/src/Microsoft.AspNetCore.OData/Routing/Conventions/DynamicPropertyRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using Microsoft.AspNet.OData.Adapters;
@@ -24,4 +28,4 @@ public override string SelectAction(RouteContext routeContext, SelectControllerR
new WebApiActionMap(actionDescriptors));
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNetCore.OData/Routing/Conventions/EntityRoutingConvention.cs b/src/Microsoft.AspNetCore.OData/Routing/Conventions/EntityRoutingConvention.cs
index d5817d85b9..7150a96ade 100644
--- a/src/Microsoft.AspNetCore.OData/Routing/Conventions/EntityRoutingConvention.cs
+++ b/src/Microsoft.AspNetCore.OData/Routing/Conventions/EntityRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using Microsoft.AspNet.OData.Adapters;
diff --git a/src/Microsoft.AspNetCore.OData/Routing/Conventions/EntitySetRoutingConvention.cs b/src/Microsoft.AspNetCore.OData/Routing/Conventions/EntitySetRoutingConvention.cs
index e29941c95a..66376aa74b 100644
--- a/src/Microsoft.AspNetCore.OData/Routing/Conventions/EntitySetRoutingConvention.cs
+++ b/src/Microsoft.AspNetCore.OData/Routing/Conventions/EntitySetRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using Microsoft.AspNet.OData.Adapters;
diff --git a/src/Microsoft.AspNetCore.OData/Routing/Conventions/FunctionRoutingConvention.cs b/src/Microsoft.AspNetCore.OData/Routing/Conventions/FunctionRoutingConvention.cs
index bddba5882d..73163ed72e 100644
--- a/src/Microsoft.AspNetCore.OData/Routing/Conventions/FunctionRoutingConvention.cs
+++ b/src/Microsoft.AspNetCore.OData/Routing/Conventions/FunctionRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using Microsoft.AspNet.OData.Adapters;
diff --git a/src/Microsoft.AspNetCore.OData/Routing/Conventions/IODataRoutingConvention.cs b/src/Microsoft.AspNetCore.OData/Routing/Conventions/IODataRoutingConvention.cs
index 2040addd75..ca6e5b3d4c 100644
--- a/src/Microsoft.AspNetCore.OData/Routing/Conventions/IODataRoutingConvention.cs
+++ b/src/Microsoft.AspNetCore.OData/Routing/Conventions/IODataRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc.Abstractions;
@@ -23,4 +27,4 @@ public interface IODataRoutingConvention
///
IEnumerable SelectAction(RouteContext routeContext);
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNetCore.OData/Routing/Conventions/MetadataRoutingConvention.cs b/src/Microsoft.AspNetCore.OData/Routing/Conventions/MetadataRoutingConvention.cs
index c685e7081d..6511fe6db7 100644
--- a/src/Microsoft.AspNetCore.OData/Routing/Conventions/MetadataRoutingConvention.cs
+++ b/src/Microsoft.AspNetCore.OData/Routing/Conventions/MetadataRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
@@ -56,4 +60,4 @@ public IEnumerable SelectAction(RouteContext routeCo
return null;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNetCore.OData/Routing/Conventions/NavigationRoutingConvention.cs b/src/Microsoft.AspNetCore.OData/Routing/Conventions/NavigationRoutingConvention.cs
index fd894041f2..0a5f5f00bd 100644
--- a/src/Microsoft.AspNetCore.OData/Routing/Conventions/NavigationRoutingConvention.cs
+++ b/src/Microsoft.AspNetCore.OData/Routing/Conventions/NavigationRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using Microsoft.AspNet.OData.Adapters;
diff --git a/src/Microsoft.AspNetCore.OData/Routing/Conventions/NavigationSourceRoutingConvention.cs b/src/Microsoft.AspNetCore.OData/Routing/Conventions/NavigationSourceRoutingConvention.cs
index 7b8dfa93c6..f47f8eb3a3 100644
--- a/src/Microsoft.AspNetCore.OData/Routing/Conventions/NavigationSourceRoutingConvention.cs
+++ b/src/Microsoft.AspNetCore.OData/Routing/Conventions/NavigationSourceRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.AspNetCore.OData/Routing/Conventions/NestedPathsRoutingConvention.cs b/src/Microsoft.AspNetCore.OData/Routing/Conventions/NestedPathsRoutingConvention.cs
new file mode 100644
index 0000000000..2d1d2ff2b4
--- /dev/null
+++ b/src/Microsoft.AspNetCore.OData/Routing/Conventions/NestedPathsRoutingConvention.cs
@@ -0,0 +1,31 @@
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
+
+using System.Collections.Generic;
+using Microsoft.AspNet.OData.Adapters;
+using Microsoft.AspNet.OData.Extensions;
+using Microsoft.AspNetCore.Mvc.Controllers;
+using Microsoft.AspNetCore.Routing;
+
+namespace Microsoft.AspNet.OData.Routing.Conventions
+{
+ ///
+ /// An implementation of that handles GET requests with arbitrarily nested paths.
+ ///
+ public partial class NestedPathsRoutingConvention
+ {
+ ///
+ /// This signature uses types that are AspNetCore-specific.
+ public override string SelectAction(RouteContext routeContext, SelectControllerResult controllerResult, IEnumerable actionDescriptors)
+ {
+ return SelectActionImpl(
+ routeContext.HttpContext.ODataFeature().Path,
+ new WebApiControllerContext(routeContext, controllerResult),
+ new WebApiActionMap(actionDescriptors));
+ }
+ }
+}
diff --git a/src/Microsoft.AspNetCore.OData/Routing/Conventions/ODataRoutingConventions.cs b/src/Microsoft.AspNetCore.OData/Routing/Conventions/ODataRoutingConventions.cs
index 5033ddd93b..226c12cf70 100644
--- a/src/Microsoft.AspNetCore.OData/Routing/Conventions/ODataRoutingConventions.cs
+++ b/src/Microsoft.AspNetCore.OData/Routing/Conventions/ODataRoutingConventions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
@@ -77,8 +81,9 @@ public static IList CreateDefault()
new RefRoutingConvention(),
new ActionRoutingConvention(),
new FunctionRoutingConvention(),
+ new NestedPathsRoutingConvention(),
new UnmappedRequestRoutingConvention()
};
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNetCore.OData/Routing/Conventions/OperationImportRoutingConvention.cs b/src/Microsoft.AspNetCore.OData/Routing/Conventions/OperationImportRoutingConvention.cs
index 068d044e53..fba01d1ccf 100644
--- a/src/Microsoft.AspNetCore.OData/Routing/Conventions/OperationImportRoutingConvention.cs
+++ b/src/Microsoft.AspNetCore.OData/Routing/Conventions/OperationImportRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using Microsoft.AspNet.OData.Adapters;
diff --git a/src/Microsoft.AspNetCore.OData/Routing/Conventions/PropertyRoutingConvention.cs b/src/Microsoft.AspNetCore.OData/Routing/Conventions/PropertyRoutingConvention.cs
index bb6952d7ea..1e0222a293 100644
--- a/src/Microsoft.AspNetCore.OData/Routing/Conventions/PropertyRoutingConvention.cs
+++ b/src/Microsoft.AspNetCore.OData/Routing/Conventions/PropertyRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using Microsoft.AspNet.OData.Adapters;
diff --git a/src/Microsoft.AspNetCore.OData/Routing/Conventions/RefRoutingConvention.cs b/src/Microsoft.AspNetCore.OData/Routing/Conventions/RefRoutingConvention.cs
index f8e996d297..4114d37f73 100644
--- a/src/Microsoft.AspNetCore.OData/Routing/Conventions/RefRoutingConvention.cs
+++ b/src/Microsoft.AspNetCore.OData/Routing/Conventions/RefRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using Microsoft.AspNet.OData.Adapters;
@@ -24,4 +28,4 @@ public override string SelectAction(RouteContext routeContext, SelectControllerR
new WebApiActionMap(actionDescriptors));
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNetCore.OData/Routing/Conventions/SingletonRoutingConvention.cs b/src/Microsoft.AspNetCore.OData/Routing/Conventions/SingletonRoutingConvention.cs
index 213fe0e031..6d597adf48 100644
--- a/src/Microsoft.AspNetCore.OData/Routing/Conventions/SingletonRoutingConvention.cs
+++ b/src/Microsoft.AspNetCore.OData/Routing/Conventions/SingletonRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using Microsoft.AspNet.OData.Adapters;
diff --git a/src/Microsoft.AspNetCore.OData/Routing/Conventions/UnmappedRequestRoutingConvention.cs b/src/Microsoft.AspNetCore.OData/Routing/Conventions/UnmappedRequestRoutingConvention.cs
index 5a28ac46f6..0f74712e18 100644
--- a/src/Microsoft.AspNetCore.OData/Routing/Conventions/UnmappedRequestRoutingConvention.cs
+++ b/src/Microsoft.AspNetCore.OData/Routing/Conventions/UnmappedRequestRoutingConvention.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using Microsoft.AspNet.OData.Adapters;
diff --git a/src/Microsoft.AspNetCore.OData/Routing/ODataActionSelector.cs b/src/Microsoft.AspNetCore.OData/Routing/ODataActionSelector.cs
index 676387f780..3289dac7da 100644
--- a/src/Microsoft.AspNetCore.OData/Routing/ODataActionSelector.cs
+++ b/src/Microsoft.AspNetCore.OData/Routing/ODataActionSelector.cs
@@ -1,10 +1,15 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
+using System.Reflection;
using Microsoft.AspNet.OData.Common;
using Microsoft.AspNet.OData.Extensions;
using Microsoft.AspNet.OData.Routing.Conventions;
@@ -136,7 +141,7 @@ public ActionDescriptor SelectBestCandidate(RouteContext context, IReadOnlyList<
// Filter out types we know how to bind out of the parameter lists. These values
// do not show up in RouteData() but will bind properly later.
- var considerCandidates = candidates
+ IEnumerable considerCandidates = candidates
.Select(c => new ActionIdAndParameters(
id: c.Id,
parameterCount: c.Parameters.Count,
@@ -161,8 +166,8 @@ public ActionDescriptor SelectBestCandidate(RouteContext context, IReadOnlyList<
// Method(key,ODataQueryOptions) vs Method(key).
// Method(key,relatedKey) vs Method(key).
// Method(key,relatedKey,ODataPath) vs Method(key,relatedKey).
- var matchedCandidates = considerCandidates
- .Where(c => TryMatch(context, c.FilteredParameters, availableKeys,
+ List matchedCandidates = considerCandidates
+ .Where(c => TryMatch(context, c.ActionDescriptor, c.FilteredParameters, availableKeys,
optionalWrapper, c.TotalParameterCount, availableKeysCount))
.OrderByDescending(c => c.FilteredParameters.Count)
.ThenByDescending(c => c.TotalParameterCount)
@@ -173,7 +178,7 @@ public ActionDescriptor SelectBestCandidate(RouteContext context, IReadOnlyList<
{
// prioritize actions which explicitly declare the request method
// e.g. using [AcceptVerbs("POST")], [HttpPost], etc.
- var bestCandidate = matchedCandidates.FirstOrDefault(candidate =>
+ ActionIdAndParameters bestCandidate = matchedCandidates.FirstOrDefault(candidate =>
ActionAcceptsMethod(candidate.ActionDescriptor as ControllerActionDescriptor, context.HttpContext.Request.Method));
if (bestCandidate != null)
{
@@ -203,6 +208,7 @@ public ActionDescriptor SelectBestCandidate(RouteContext context, IReadOnlyList<
/// of the action with the data in the route.
///
/// The current
+ /// The action descriptor
/// Parameters of the action. This excludes the and parameters
/// The names of the keys found in the uri (entity set keys, related keys, operation parameters)
/// Used to check whether a parameter is optional
@@ -212,12 +218,26 @@ public ActionDescriptor SelectBestCandidate(RouteContext context, IReadOnlyList<
///
private bool TryMatch(
RouteContext context,
+ ActionDescriptor actionDescriptor,
IList parameters,
IList availableKeys,
ODataOptionalParameter optionalWrapper,
int totalParameterCount,
int availableKeysCount)
{
+
+ // if action has [EnableNestedPaths] attribute, then it doesn't
+ // need to match parameters, since this action is expected to
+ // match arbitrarily nested paths even if it doesn't have any parameters
+ if (actionDescriptor is ControllerActionDescriptor controllerActionDescriptor)
+ {
+ if (controllerActionDescriptor.MethodInfo
+ .GetCustomAttributes().Any())
+ {
+ return true;
+ }
+ }
+
// navigationProperty is optional in some cases, therefore an action
// should not be rejected simply because it does not declare a navigationProperty parameter
if (availableKeys.Contains(ODataRouteConstants.NavigationProperty.ToLowerInvariant()))
@@ -233,9 +253,9 @@ private bool TryMatch(
}
bool matchedBody = false;
- var conventionsStore = context.HttpContext.ODataFeature().RoutingConventionsStore;
+ IDictionary conventionsStore = context.HttpContext.ODataFeature().RoutingConventionsStore;
// use the parameter name to match.
- foreach (var p in parameters)
+ foreach (ParameterDescriptor p in parameters)
{
string parameterName = p.Name.ToLowerInvariant();
if (availableKeys.Contains(parameterName))
@@ -288,7 +308,6 @@ private bool TryMatch(
return true;
}
-
private bool RequestHasBody(RouteContext context)
{
string method = context.HttpContext.Request.Method;
@@ -311,7 +330,7 @@ private bool IsParameterFromQuery(ControllerActionDescriptor action, string para
{
Contract.Assert(action != null);
- var param = action.MethodInfo.GetParameters().FirstOrDefault(p => p.Name == paramName);
+ ParameterInfo param = action.MethodInfo.GetParameters().FirstOrDefault(p => p.Name == paramName);
if (param == null)
{
return false;
@@ -327,8 +346,8 @@ private bool ParameterHasRegisteredModelBinder(ParameterDescriptor param)
return false;
}
- var modelMetadata = _modelMetadataProvider.GetMetadataForType(param.ParameterType);
- var binderContext = new ModelBinderFactoryContext()
+ ModelMetadata modelMetadata = _modelMetadataProvider.GetMetadataForType(param.ParameterType);
+ ModelBinderFactoryContext binderContext = new ModelBinderFactoryContext()
{
Metadata = modelMetadata,
BindingInfo = param.BindingInfo,
@@ -338,7 +357,7 @@ private bool ParameterHasRegisteredModelBinder(ParameterDescriptor param)
try
{
- var binder = _modelBinderFactory.CreateBinder(binderContext);
+ IModelBinder binder = _modelBinderFactory.CreateBinder(binderContext);
// ignore some built-in model binders because we already account for parameters that come from the request
return (!(binder is SimpleTypeModelBinder)
&& !(binder is BodyModelBinder)
diff --git a/src/Microsoft.AspNetCore.OData/Routing/ODataPathParameterBindingAttribute.cs b/src/Microsoft.AspNetCore.OData/Routing/ODataPathParameterBindingAttribute.cs
index 1bad81fb82..68563e0a99 100644
--- a/src/Microsoft.AspNetCore.OData/Routing/ODataPathParameterBindingAttribute.cs
+++ b/src/Microsoft.AspNetCore.OData/Routing/ODataPathParameterBindingAttribute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Threading.Tasks;
diff --git a/src/Microsoft.AspNetCore.OData/Routing/ODataPathRouteConstraint.cs b/src/Microsoft.AspNetCore.OData/Routing/ODataPathRouteConstraint.cs
index 365a590a37..ce4eaded0f 100644
--- a/src/Microsoft.AspNetCore.OData/Routing/ODataPathRouteConstraint.cs
+++ b/src/Microsoft.AspNetCore.OData/Routing/ODataPathRouteConstraint.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.AspNet.OData.Common;
diff --git a/src/Microsoft.AspNetCore.OData/Routing/ODataRoute.cs b/src/Microsoft.AspNetCore.OData/Routing/ODataRoute.cs
index 3ace371d70..4a1c24937d 100644
--- a/src/Microsoft.AspNetCore.OData/Routing/ODataRoute.cs
+++ b/src/Microsoft.AspNetCore.OData/Routing/ODataRoute.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Diagnostics.Contracts;
using Microsoft.AspNetCore.Routing;
@@ -118,4 +122,4 @@ internal VirtualPathData GenerateLinkDirectly(string odataPath)
return new VirtualPathData(this, link);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNetCore.OData/Routing/ODataVersionConstraint.cs b/src/Microsoft.AspNetCore.OData/Routing/ODataVersionConstraint.cs
index cd65aec52a..a40832a030 100644
--- a/src/Microsoft.AspNetCore.OData/Routing/ODataVersionConstraint.cs
+++ b/src/Microsoft.AspNetCore.OData/Routing/ODataVersionConstraint.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Linq;
diff --git a/src/Microsoft.AspNetCore.OData/SingleResult.cs b/src/Microsoft.AspNetCore.OData/SingleResult.cs
index f81744f400..62a8dcd71d 100644
--- a/src/Microsoft.AspNetCore.OData/SingleResult.cs
+++ b/src/Microsoft.AspNetCore.OData/SingleResult.cs
@@ -1,4 +1,11 @@
-// Copyright (c) .NET Foundation. All rights reserved.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
+
+// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Linq;
@@ -44,4 +51,4 @@ public static SingleResult Create(IQueryable queryable)
return new SingleResult(queryable);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.AspNetCore.OData/SingleResultOfT.cs b/src/Microsoft.AspNetCore.OData/SingleResultOfT.cs
index 9bc2b91dbe..86e1e1c521 100644
--- a/src/Microsoft.AspNetCore.OData/SingleResultOfT.cs
+++ b/src/Microsoft.AspNetCore.OData/SingleResultOfT.cs
@@ -1,5 +1,9 @@
-// Copyright (c) .NET Foundation. All rights reserved.
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Linq;
@@ -32,4 +36,4 @@ public SingleResult(IQueryable queryable)
}
}
}
-}
\ No newline at end of file
+}
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Aggregation/AggregationContextCore.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Aggregation/AggregationContextCore.cs
index 8508de17c8..5f42c32d78 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Aggregation/AggregationContextCore.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Aggregation/AggregationContextCore.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using Microsoft.EntityFrameworkCore;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Aggregation/AggregationController.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Aggregation/AggregationController.cs
index e44dee2b5b..c8abcc428e 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Aggregation/AggregationController.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Aggregation/AggregationController.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Aggregation/AggregationDataModel.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Aggregation/AggregationDataModel.cs
index 88b80c525d..43f3eddd70 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Aggregation/AggregationDataModel.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Aggregation/AggregationDataModel.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Aggregation/AggregationEdmModel.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Aggregation/AggregationEdmModel.cs
index 3e16ee89e0..45c0068413 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Aggregation/AggregationEdmModel.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Aggregation/AggregationEdmModel.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Aggregation/AggregationTests.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Aggregation/AggregationTests.cs
index 1f7c43815f..39900c008a 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Aggregation/AggregationTests.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Aggregation/AggregationTests.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Linq;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Aggregation/LinqToSqlDatabaseContext.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Aggregation/LinqToSqlDatabaseContext.cs
index e3793a2612..727c4bac0a 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Aggregation/LinqToSqlDatabaseContext.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Aggregation/LinqToSqlDatabaseContext.cs
@@ -1,4 +1,11 @@
-using System;
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
+
+using System;
using System.Collections.Generic;
using System.Data.Linq;
using System.Linq;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Aggregation/PagedAggregationTests.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Aggregation/PagedAggregationTests.cs
index f7e85f9922..0560ddd304 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Aggregation/PagedAggregationTests.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Aggregation/PagedAggregationTests.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Net;
using System.Net.Http;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Aggregation/PagedCustomersController.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Aggregation/PagedCustomersController.cs
index b1f7089c5c..2d3314b43e 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Aggregation/PagedCustomersController.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Aggregation/PagedCustomersController.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Linq;
using Microsoft.AspNet.OData;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/AlternateKeys/AlternateKeysController.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/AlternateKeys/AlternateKeysController.cs
index c1425c06ca..21dea0a2ac 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/AlternateKeys/AlternateKeysController.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/AlternateKeys/AlternateKeysController.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/AlternateKeys/AlternateKeysDataSource.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/AlternateKeys/AlternateKeysDataSource.cs
index 8639c63fb5..31c3b59700 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/AlternateKeys/AlternateKeysDataSource.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/AlternateKeys/AlternateKeysDataSource.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/AlternateKeys/AlternateKeysEdmModel.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/AlternateKeys/AlternateKeysEdmModel.cs
index 5e93eb686d..70c89d18cd 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/AlternateKeys/AlternateKeysEdmModel.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/AlternateKeys/AlternateKeysEdmModel.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using Microsoft.OData.Edm;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/AlternateKeys/AlternateKeysTest.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/AlternateKeys/AlternateKeysTest.cs
index a19697b036..c5ebc50d2b 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/AlternateKeys/AlternateKeysTest.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/AlternateKeys/AlternateKeysTest.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Net;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/AutoExpand/AutoExpandController.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/AutoExpand/AutoExpandController.cs
index 35b764ab0d..72f14ab870 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/AutoExpand/AutoExpandController.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/AutoExpand/AutoExpandController.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Linq;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/AutoExpand/AutoExpandDataModel.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/AutoExpand/AutoExpandDataModel.cs
index c79f98acf9..f68eef2f03 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/AutoExpand/AutoExpandDataModel.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/AutoExpand/AutoExpandDataModel.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Data.Entity;
using Microsoft.AspNet.OData.Builder;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/AutoExpand/AutoExpandEdmModel.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/AutoExpand/AutoExpandEdmModel.cs
index 8eec10dfc2..851150e7eb 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/AutoExpand/AutoExpandEdmModel.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/AutoExpand/AutoExpandEdmModel.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.OData.Edm;
using Microsoft.Test.E2E.AspNet.OData.Common.Execution;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/AutoExpand/AutoExpandTests.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/AutoExpand/AutoExpandTests.cs
index 4e26a2b1d3..081f7a3415 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/AutoExpand/AutoExpandTests.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/AutoExpand/AutoExpandTests.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Linq;
using System.Net;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Batch/Client/DefaultBatchGeneratedClient.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Batch/Client/DefaultBatchGeneratedClient.cs
index 65fe97f269..a0ae79eb6f 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Batch/Client/DefaultBatchGeneratedClient.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Batch/Client/DefaultBatchGeneratedClient.cs
@@ -1,4 +1,11 @@
-//------------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
//
// This code was generated by a tool.
// Runtime Version:4.0.30319.34011
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Batch/Client/UnbufferedBatchGeneratedClient.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Batch/Client/UnbufferedBatchGeneratedClient.cs
index ae774230b3..d97b317370 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Batch/Client/UnbufferedBatchGeneratedClient.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Batch/Client/UnbufferedBatchGeneratedClient.cs
@@ -1,4 +1,11 @@
-//------------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
//
// This code was generated by a tool.
// Runtime Version:4.0.30319.34011
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Batch/Tests/DataServicesClient/DefaultODataBatchHandlerTests.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Batch/Tests/DataServicesClient/DefaultODataBatchHandlerTests.cs
index 9572ce955c..46e62ac6e7 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Batch/Tests/DataServicesClient/DefaultODataBatchHandlerTests.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Batch/Tests/DataServicesClient/DefaultODataBatchHandlerTests.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Batch/Tests/DataServicesClient/UnbufferedODataBatchHandlerTests.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Batch/Tests/DataServicesClient/UnbufferedODataBatchHandlerTests.cs
index be868b0c0b..f716a02dcf 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Batch/Tests/DataServicesClient/UnbufferedODataBatchHandlerTests.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Batch/Tests/DataServicesClient/UnbufferedODataBatchHandlerTests.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/BoundOperation/BoundOperationContextUriTest.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/BoundOperation/BoundOperationContextUriTest.cs
index e474efa2b7..e4938830ba 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/BoundOperation/BoundOperationContextUriTest.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/BoundOperation/BoundOperationContextUriTest.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Net.Http;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/BoundOperation/BoundOperationController.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/BoundOperation/BoundOperationController.cs
index 7e7815b15f..ae3cc13b7c 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/BoundOperation/BoundOperationController.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/BoundOperation/BoundOperationController.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/BoundOperation/BoundOperationDataModel.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/BoundOperation/BoundOperationDataModel.cs
index 89f5360223..570b654658 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/BoundOperation/BoundOperationDataModel.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/BoundOperation/BoundOperationDataModel.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/BoundOperation/BoundOperationEdmModel.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/BoundOperation/BoundOperationEdmModel.cs
index a6f0af2d24..36b7e1a772 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/BoundOperation/BoundOperationEdmModel.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/BoundOperation/BoundOperationEdmModel.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Builder;
using Microsoft.OData.Edm;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/BoundOperation/BoundOperationTest.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/BoundOperation/BoundOperationTest.cs
index 38be5fee6a..2d6aee591a 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/BoundOperation/BoundOperationTest.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/BoundOperation/BoundOperationTest.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/Aggregation/LinqToSqlDatabaseContext.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/Aggregation/LinqToSqlDatabaseContext.cs
index e3793a2612..727c4bac0a 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/Aggregation/LinqToSqlDatabaseContext.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/Aggregation/LinqToSqlDatabaseContext.cs
@@ -1,4 +1,11 @@
-using System;
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
+
+using System;
using System.Collections.Generic;
using System.Data.Linq;
using System.Linq;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/Formatter/JsonLight/Metadata/Extensions/HttpRequestMessageExtensions.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/Formatter/JsonLight/Metadata/Extensions/HttpRequestMessageExtensions.cs
index 2b741043e7..a9120a9e1c 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/Formatter/JsonLight/Metadata/Extensions/HttpRequestMessageExtensions.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/Formatter/JsonLight/Metadata/Extensions/HttpRequestMessageExtensions.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/Formatter/ODataEntityReferenceLinkE2ETests.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/Formatter/ODataEntityReferenceLinkE2ETests.cs
new file mode 100644
index 0000000000..40ff2933b3
--- /dev/null
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/Formatter/ODataEntityReferenceLinkE2ETests.cs
@@ -0,0 +1,276 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Data.Entity;
+using System.Linq;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Threading.Tasks;
+using Microsoft.AspNet.OData;
+using Microsoft.AspNet.OData.Extensions;
+using Microsoft.AspNet.OData.Routing;
+using Microsoft.OData.Edm;
+using Microsoft.Test.E2E.AspNet.OData.Common.Controllers;
+using Microsoft.Test.E2E.AspNet.OData.Common.Execution;
+using Newtonsoft.Json.Linq;
+using Xunit;
+
+namespace Microsoft.Test.E2E.AspNet.OData.Formatter
+{
+ public class ODataEntityReferenceLinkE2ETests : WebHostTestBase
+ {
+ public ODataEntityReferenceLinkE2ETests(WebHostTestFixture fixture)
+ : base(fixture)
+ {
+ }
+ protected override void UpdateConfiguration(WebRouteConfiguration configuration)
+ {
+ var controllers = new[] { typeof(BooksController)};
+ configuration.AddControllers(controllers);
+ configuration.Count().Filter().OrderBy().Expand().MaxTop(null).Select();
+ configuration.MapODataServiceRoute("odata", "odata", BuildEdmModel(configuration));
+ }
+ private static IEdmModel BuildEdmModel(WebRouteConfiguration configuration)
+ {
+ var builder = configuration.CreateConventionModelBuilder();
+ builder.EntitySet("Books");
+ builder.EntitySet("Authors");
+ builder.Action("ResetDataSource");
+ builder.Action("RelateToExistingEntityAndUpdate").ReturnsFromEntitySet("Books").EntityParameter("book");
+
+ return builder.GetEdmModel();
+ }
+
+ [Fact]
+ public async Task CanCreate_ANewEntityAndRelateToAnExistingEntity_UsingODataBind()
+ {
+ await ResetDataSource();
+ // Arrange
+ const string Payload = "{" +
+ "\"Id\":\"1\"," +
+ "\"Name\":\"BookA\"," +
+ "\"Author@odata.bind\":\"Authors(1)\"}";
+
+ string Uri = BaseAddress + "/odata/Books";
+ HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, Uri);
+
+ request.Content = new StringContent(Payload);
+ request.Content.Headers.ContentType = MediaTypeWithQualityHeaderValue.Parse("application/json");
+
+ // Act
+ HttpResponseMessage response = await Client.SendAsync(request);
+
+ // Assert
+ Assert.True(response.IsSuccessStatusCode);
+ Assert.Equal(HttpStatusCode.Created, response.StatusCode);
+ Assert.NotNull(response.Content);
+
+ //Get the above saved entity from the database
+ //and expand the navigation property to see if
+ //it was correctly created with the existing entity
+ //attached to it.
+ string query = string.Format("{0}/odata/Books?$expand=Author", BaseAddress);
+ HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Get, query);
+ request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/json"));
+
+ // Act
+ HttpResponseMessage res = await Client.SendAsync(requestMessage);
+
+ // Assert
+ Assert.True(res.IsSuccessStatusCode);
+ var responseObject = JObject.Parse(await res.Content.ReadAsStringAsync());
+ var result = responseObject["value"] as JArray;
+ var expandProp = result[0]["Author"] as JObject;
+ Assert.Equal(1, expandProp["Id"]);
+
+ }
+
+ [Fact]
+ public async Task CanUpdate_TheRelatedEntitiesProperties()
+ {
+ await ResetDataSource();
+ // Arrange
+ const string Payload = "{" +
+ "\"book\":{" +
+ "\"Id\":\"1\"," +
+ "\"Name\":\"BookA\"," +
+ "\"Author\":{" +
+ "\"@odata.id\":\"Authors(1)\"," +
+ "\"Name\":\"UpdatedAuthor\"}}}";
+
+ string Uri = BaseAddress + "/odata/RelateToExistingEntityAndUpdate";
+ HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, Uri);
+
+ request.Content = new StringContent(Payload);
+ request.Content.Headers.ContentType = MediaTypeWithQualityHeaderValue.Parse("application/json");
+
+ // Act
+ HttpResponseMessage response = await Client.SendAsync(request);
+
+ // Assert
+ Assert.True(response.IsSuccessStatusCode);
+ Assert.Equal(HttpStatusCode.Created, response.StatusCode);
+ Assert.NotNull(response.Content);
+
+ //Get the above saved entity from the database
+ //and expand its navigation property to see if it was created with
+ //the existing entity correctly.
+ //Also note that we were able to update the name property
+ //of the existing entity
+ string query = string.Format("{0}/odata/Books?$expand=Author", BaseAddress);
+ HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Get, query);
+ request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/json"));
+
+ // Act
+ HttpResponseMessage res = await Client.SendAsync(requestMessage);
+
+ // Assert
+ Assert.True(res.IsSuccessStatusCode);
+ var responseObject = JObject.Parse(await res.Content.ReadAsStringAsync());
+ var result = responseObject["value"] as JArray;
+ var expandProp = result[0]["Author"] as JObject;
+ Assert.Equal(1, expandProp["Id"]);
+ Assert.Equal("UpdatedAuthor", expandProp["Name"]);
+ }
+
+ private async Task ResetDataSource()
+ {
+ string requestUri = BaseAddress + "/odata/ResetDataSource";
+ HttpClient client = new HttpClient();
+ HttpResponseMessage response = await client.GetAsync(requestUri);
+ response.EnsureSuccessStatusCode();
+ }
+ }
+
+ public class BooksController : TestODataController
+#if NETCORE
+ , IDisposable
+#endif
+ {
+ private ODataEntityReferenceLinkContext db = new ODataEntityReferenceLinkContext();
+
+ [EnableQuery]
+ public ITestActionResult Get()
+ {
+ return Ok(db.Books);
+ }
+ public ITestActionResult Post([FromBody] Book book)
+ {
+ if (!ModelState.IsValid)
+ {
+ return BadRequest();
+ }
+
+ db.Authors.Attach(book.Author);
+ db.Books.Add(book);
+ db.SaveChanges();
+
+ return Created(book);
+ }
+
+ [HttpPost]
+ [ODataRoute("RelateToExistingEntityAndUpdate")]
+ public ITestActionResult RelateToExistingEntityAndUpdate(ODataActionParameters odataActionParameters)
+ {
+ if (!ModelState.IsValid)
+ {
+ return BadRequest();
+ }
+
+ Book book = (Book)odataActionParameters["book"];
+ string authorName = book.Author.Name;
+ Author author = new Author()
+ {
+ Id = book.Author.Id
+ };
+ db.Authors.Attach(author);
+ book.Author = author;
+ book.Author.Name = authorName;
+ db.Books.Add(book);
+
+ db.SaveChanges();
+ return Created(book);
+ }
+
+ [HttpGet]
+ [ODataRoute("ResetDataSource")]
+ public ITestActionResult ResetDataSource()
+ {
+ db.Database.Delete(); // Start from scratch so that tests aren't broken by schema changes.
+ CreateDatabase();
+ return Ok();
+ }
+
+ private static void CreateDatabase()
+ {
+ using (ODataEntityReferenceLinkContext db = new ODataEntityReferenceLinkContext())
+ {
+ if (!db.Authors.Any())
+ {
+ IList authors = new List()
+ {
+ new Author()
+ {
+ Id = 1,
+ Name = "AuthorA"
+ },
+ new Author()
+ {
+ Id = 2,
+ Name = "AuthorB"
+ },
+ new Author()
+ {
+ Id = 3,
+ Name = "AuthorC"
+ }
+ };
+
+ foreach (var author in authors)
+ {
+ db.Authors.Add(author);
+ }
+ db.SaveChanges();
+ }
+ }
+ }
+
+#if NETCORE
+ public void Dispose()
+ {
+ //_db.Dispose();
+ }
+#endif
+
+ }
+
+ public class Book
+ {
+ [Key]
+ public int Id { get; set; }
+ public string Name { get; set; }
+ public Author Author { get; set; }
+ public IList AuthorList { get; set; }
+ }
+
+ public class Author
+ {
+ [Key]
+ public int Id { get; set; }
+ public string Name { get; set; }
+ }
+
+ public class ODataEntityReferenceLinkContext : DbContext
+ {
+ public static string ConnectionString = @"Data Source=(LocalDb)\MSSQLLocalDB;Integrated Security=True;Initial Catalog=ODataEntityReferenceLinkContext";
+ public ODataEntityReferenceLinkContext()
+ : base(ConnectionString)
+ {
+ }
+ public DbSet Books { get; set; }
+ public DbSet Authors { get; set; }
+ }
+}
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/InstanceAnnotations/AnnotationController.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/InstanceAnnotations/AnnotationController.cs
index 92f1a994c5..6f14795a5b 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/InstanceAnnotations/AnnotationController.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/InstanceAnnotations/AnnotationController.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Linq;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/InstanceAnnotations/AnnotationDataModel.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/InstanceAnnotations/AnnotationDataModel.cs
index 9eaaa27c67..e001bd6d28 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/InstanceAnnotations/AnnotationDataModel.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/InstanceAnnotations/AnnotationDataModel.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.AspNet.OData.Builder;
using System;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/InstanceAnnotations/AnnotationEdmModel.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/InstanceAnnotations/AnnotationEdmModel.cs
index eebb7327df..f1c1229525 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/InstanceAnnotations/AnnotationEdmModel.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/InstanceAnnotations/AnnotationEdmModel.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/InstanceAnnotations/AnnotationTest.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/InstanceAnnotations/AnnotationTest.cs
index 2ee6692369..d50a510425 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/InstanceAnnotations/AnnotationTest.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/InstanceAnnotations/AnnotationTest.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
@@ -239,4 +243,4 @@ private void VerifyInstanceAnnotations(string name, string json)
}
}
}
-}
\ No newline at end of file
+}
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/Microsoft.Test.E2E.AspNet.OData.csproj b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/Microsoft.Test.E2E.AspNet.OData.csproj
index 6b439e284b..d8f39cbbc7 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/Microsoft.Test.E2E.AspNet.OData.csproj
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/Microsoft.Test.E2E.AspNet.OData.csproj
@@ -35,14 +35,14 @@
..\..\..\..\sln\packages\Microsoft.Data.OData.5.8.4\lib\net40\Microsoft.Data.OData.dll
True
-
- ..\..\..\..\sln\packages\Microsoft.OData.Client.7.9.0\lib\net45\Microsoft.OData.Client.dll
+
+ ..\..\..\..\sln\packages\Microsoft.OData.Client.7.9.1\lib\net45\Microsoft.OData.Client.dll
-
- ..\..\..\..\sln\packages\Microsoft.OData.Core.7.9.0\lib\net45\Microsoft.OData.Core.dll
+
+ ..\..\..\..\sln\packages\Microsoft.OData.Core.7.9.1\lib\net45\Microsoft.OData.Core.dll
-
- ..\..\..\..\sln\packages\Microsoft.OData.Edm.7.9.0\lib\net45\Microsoft.OData.Edm.dll
+
+ ..\..\..\..\sln\packages\Microsoft.OData.Edm.7.9.1\lib\net45\Microsoft.OData.Edm.dll
..\..\..\..\sln\packages\Microsoft.Owin.2.0.2\lib\net45\Microsoft.Owin.dll
@@ -56,8 +56,8 @@
..\..\..\..\sln\packages\Microsoft.Owin.Hosting.2.0.2\lib\net45\Microsoft.Owin.Hosting.dll
True
-
- ..\..\..\..\sln\packages\Microsoft.Spatial.7.9.0\lib\net45\Microsoft.Spatial.dll
+
+ ..\..\..\..\sln\packages\Microsoft.Spatial.7.9.1\lib\net45\Microsoft.Spatial.dll
True
@@ -151,6 +151,21 @@
Aggregation\AggregationTests.cs
+
+ BulkOperation\BulkInsertDataModel.cs
+
+
+ BulkOperation\BulkInsertEdmModel.cs
+
+
+ BulkOperation\BulkInsertTest.cs
+
+
+ BulkOperation\BulkInsertController.cs
+
+
+ BulkOperation\BulkOperationPatchHandlers.cs
+
EntitySetAggregation\EntitySetAggregationController.cs
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/Properties/AssemblyInfo.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/Properties/AssemblyInfo.cs
index 21d248af39..cd14d4cfe6 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/Properties/AssemblyInfo.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/Properties/AssemblyInfo.cs
@@ -1,4 +1,11 @@
-using System.Reflection;
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
+
+using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/UriParserExtension/UriResolverDependencyTestWithOldDefaultConfig.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/UriParserExtension/UriResolverDependencyTestWithOldDefaultConfig.cs
index 03318071e1..eb50eb4950 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/UriParserExtension/UriResolverDependencyTestWithOldDefaultConfig.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/UriParserExtension/UriResolverDependencyTestWithOldDefaultConfig.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Net;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/packages.config b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/packages.config
index 4d57b0c00e..d063b15ca5 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/packages.config
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/packages.config
@@ -10,13 +10,13 @@
-
-
-
+
+
+
-
+
@@ -46,7 +46,7 @@
-
+
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore/Aggregation/LinqToSqlDatabaseContext.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore/Aggregation/LinqToSqlDatabaseContext.cs
index e69da2f725..727c4bac0a 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore/Aggregation/LinqToSqlDatabaseContext.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore/Aggregation/LinqToSqlDatabaseContext.cs
@@ -1,4 +1,11 @@
-using System;
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
+
+using System;
using System.Collections.Generic;
using System.Data.Linq;
using System.Linq;
@@ -17,4 +24,4 @@ public LinqToSqlDatabaseContext() :
public Table Customers { get; set; }
}
-}
\ No newline at end of file
+}
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore/DependencyInjection/CustomizeSkipTokenImplementationTest.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore/DependencyInjection/CustomizeSkipTokenImplementationTest.cs
index 406a4cbc60..2feb47a7f8 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore/DependencyInjection/CustomizeSkipTokenImplementationTest.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore/DependencyInjection/CustomizeSkipTokenImplementationTest.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore/Microsoft.Test.E2E.AspNetCore.OData.csproj b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore/Microsoft.Test.E2E.AspNetCore.OData.csproj
index 90cd827f5f..9ca7c3050d 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore/Microsoft.Test.E2E.AspNetCore.OData.csproj
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore/Microsoft.Test.E2E.AspNetCore.OData.csproj
@@ -1399,6 +1399,18 @@
OpenType\TypedTest.cs
+
+ BulkOperation\BulkInsertDataModel.cs
+
+
+ BulkOperation\BulkInsertEdmModel.cs
+
+
+ BulkOperation\BulkInsertController.cs
+
+
+ BulkOperation\BulkOperationPatchHandlers.cs
+
ParameterAlias\ParameterAliasDataSource.cs
@@ -1843,17 +1855,17 @@
..\..\..\..\sln\packages\Microsoft.Net.Http.Headers.2.0.3\lib\netstandard2.0\Microsoft.Net.Http.Headers.dll
-
- ..\..\..\..\sln\packages\Microsoft.OData.Client.7.9.0\lib\net45\Microsoft.OData.Client.dll
+
+ ..\..\..\..\sln\packages\Microsoft.OData.Client.7.9.1\lib\net45\Microsoft.OData.Client.dll
-
- ..\..\..\..\sln\packages\Microsoft.OData.Core.7.9.0\lib\net45\Microsoft.OData.Core.dll
+
+ ..\..\..\..\sln\packages\Microsoft.OData.Core.7.9.1\lib\net45\Microsoft.OData.Core.dll
-
- ..\..\..\..\sln\packages\Microsoft.OData.Edm.7.9.0\lib\net45\Microsoft.OData.Edm.dll
+
+ ..\..\..\..\sln\packages\Microsoft.OData.Edm.7.9.1\lib\net45\Microsoft.OData.Edm.dll
-
- ..\..\..\..\sln\packages\Microsoft.Spatial.7.9.0\lib\net45\Microsoft.Spatial.dll
+
+ ..\..\..\..\sln\packages\Microsoft.Spatial.7.9.1\lib\net45\Microsoft.Spatial.dll
..\..\..\..\sln\packages\Newtonsoft.Json.10.0.1\lib\net45\Newtonsoft.Json.dll
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore/Properties/AssemblyInfo.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore/Properties/AssemblyInfo.cs
index bd6f826702..2e2249cfe5 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore/Properties/AssemblyInfo.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore/Properties/AssemblyInfo.cs
@@ -1,4 +1,11 @@
-using System.Reflection;
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
+
+using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore/packages.config b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore/packages.config
index 75c6cae84f..6f351abc25 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore/packages.config
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore/packages.config
@@ -61,10 +61,10 @@
-
-
-
-
+
+
+
+
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/ActionResult/ActionResultController.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/ActionResult/ActionResultController.cs
index 9548093287..81bd44c321 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/ActionResult/ActionResultController.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/ActionResult/ActionResultController.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Threading.Tasks;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/ActionResult/ActionResultEdmModel.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/ActionResult/ActionResultEdmModel.cs
index 66950fbe42..85b8987bb3 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/ActionResult/ActionResultEdmModel.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/ActionResult/ActionResultEdmModel.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.OData.Edm;
using Microsoft.Test.E2E.AspNet.OData.Common.Execution;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/ActionResult/ActionResultODataModel.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/ActionResult/ActionResultODataModel.cs
index dab22933db..ccb5214614 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/ActionResult/ActionResultODataModel.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/ActionResult/ActionResultODataModel.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/ActionResult/ActionResultTests.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/ActionResult/ActionResultTests.cs
index be389e1800..54a642f778 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/ActionResult/ActionResultTests.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/ActionResult/ActionResultTests.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Linq;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/Aggregation/LinqToSqlDatabaseContext.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/Aggregation/LinqToSqlDatabaseContext.cs
index b7ca09d329..911a0b357b 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/Aggregation/LinqToSqlDatabaseContext.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/Aggregation/LinqToSqlDatabaseContext.cs
@@ -1,4 +1,11 @@
-#if !NETCORE
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
+
+#if !NETCORE
using System;
using System.Collections.Generic;
using System.Data.Linq;
@@ -19,4 +26,4 @@ public LinqToSqlDatabaseContext() :
public Table Customers { get; set; }
}
}
-#endif
\ No newline at end of file
+#endif
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/BulkOperation/EFTests/BulkInsertTestEF.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/BulkOperation/EFTests/BulkInsertTestEF.cs
new file mode 100644
index 0000000000..5919eb09f3
--- /dev/null
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/BulkOperation/EFTests/BulkInsertTestEF.cs
@@ -0,0 +1,252 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+
+using System;
+using System.Linq;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text;
+using System.Threading.Tasks;
+using Microsoft.AspNet.OData;
+using Microsoft.AspNet.OData.Extensions;
+using Microsoft.AspNet.OData.Routing;
+using Microsoft.AspNet.OData.Routing.Conventions;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Test.E2E.AspNet.OData.BulkOperation;
+using Microsoft.Test.E2E.AspNet.OData.Common.Execution;
+using Microsoft.Test.E2E.AspNet.OData.Common.Extensions;
+using Newtonsoft.Json.Linq;
+using Xunit;
+
+namespace Microsoft.Test.E2E.AspNet.OData.BulkInsert
+{
+ public class BulkInsertTestEF : WebHostTestBase
+ {
+ public BulkInsertTestEF(WebHostTestFixture fixture)
+ :base(fixture)
+ {
+ }
+
+ protected override void UpdateConfiguration(WebRouteConfiguration configuration)
+ {
+ var controllers = new[] { typeof(EmployeesControllerEF), typeof(MetadataController) };
+ configuration.AddControllers(controllers);
+
+ configuration.Routes.Clear();
+ configuration.Count().Filter().OrderBy().Expand().MaxTop(null).Select();
+ configuration.MapODataServiceRoute("convention", "convention", BulkInsertEdmModel.GetConventionModel(configuration));
+ configuration.MapODataServiceRoute("explicit", "explicit", BulkInsertEdmModel.GetExplicitModel(configuration), new DefaultODataPathHandler(), ODataRoutingConventions.CreateDefault());
+ configuration.EnsureInitialized();
+
+ }
+
+
+ #region Update
+
+ [Fact]
+ public async Task PatchEmployee_WithUpdates()
+ {
+ //Arrange
+ string requestUri = this.BaseAddress + "/convention/Employees(1)";
+
+ var content = @"{
+ 'Name':'Sql' ,
+ 'Friends@odata.delta':[{'Id':1,'Name':'Test2'},{'Id':2,'Name':'Test3'}]
+ }";
+
+ var requestForPost = new HttpRequestMessage(new HttpMethod("PATCH"), requestUri);
+
+ StringContent stringContent = new StringContent(content: content, encoding: Encoding.UTF8, mediaType: "application/json");
+ requestForPost.Content = stringContent;
+
+ //Act & Assert
+ using (HttpResponseMessage response = await this.Client.SendAsync(requestForPost))
+ {
+ var json = await response.Content.ReadAsObject();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ Assert.Contains("Sql", json.ToString());
+ }
+
+ }
+
+ [Fact]
+ public async Task PatchEmployee_WithUpdates_WithEmployees()
+ {
+ //Arrange
+
+ string requestUri = this.BaseAddress + "/convention/Employees(1)";
+
+ var content = @"{
+ 'Name':'SqlFU' ,
+ 'Friends':[{'Id':345,'Name':'Test2'},{'Id':400,'Name':'Test3'},{'Id':900,'Name':'Test93'}]
+ }";
+
+ var requestForPost = new HttpRequestMessage(new HttpMethod("PATCH"), requestUri);
+
+ StringContent stringContent = new StringContent(content: content, encoding: Encoding.UTF8, mediaType: "application/json");
+ requestForPost.Content = stringContent;
+
+ //Act & Assert
+ using (HttpResponseMessage response = await this.Client.SendAsync(requestForPost))
+ {
+ var json = await response.Content.ReadAsObject();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ Assert.Contains("SqlFU", json.ToString());
+ }
+
+ }
+
+ [Fact]
+ public async Task PatchEmployee_WithUpdates_Employees()
+ {
+ //Arrange
+
+ string requestUri = this.BaseAddress + "/convention/Employees";
+
+ var content = @"{'@odata.context':'http://localhost:11001/convention/$metadata#Employees/$delta',
+ 'value':[{ '@odata.type': '#Microsoft.Test.E2E.AspNet.OData.BulkInsert.Employee', 'ID':1,'Name':'Employee1',
+ 'Friends@odata.delta':[{'Id':1,'Name':'Friend1',
+ 'Orders@odata.delta' :[{'Id':1,'Price': 10}, {'Id':2,'Price': 20} ] },{'Id':2,'Name':'Friend2'}]
+ },
+ { '@odata.type': '#Microsoft.Test.E2E.AspNet.OData.BulkInsert.Employee', 'ID':2,'Name':'Employee2',
+ 'Friends@odata.delta':[{'Id':3,'Name':'Friend3',
+ 'Orders@odata.delta' :[{'Id':3,'Price': 30}, {'Id':4,'Price': 40} ]},{'Id':4,'Name':'Friend4'}]
+ }]
+ }";
+
+ var requestForPost = new HttpRequestMessage(new HttpMethod("PATCH"), requestUri);
+
+ StringContent stringContent = new StringContent(content: content, encoding: Encoding.UTF8, mediaType: "application/json");
+ requestForPost.Content = stringContent;
+
+ // Act & Assert
+
+ using (HttpResponseMessage response = await this.Client.SendAsync(requestForPost))
+ {
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ var json = response.Content.ReadAsStringAsync().Result;
+ Assert.Contains("Employee1", json);
+ Assert.Contains("Employee2", json);
+ }
+
+ }
+
+
+ [Fact]
+ public async Task PatchEmployee_WithDelete()
+ {
+ //Arrange
+
+ string requestUri = this.BaseAddress + "/convention/Employees(1)";
+
+ var content = @"{
+ 'Name':'Sql',
+ 'Friends@odata.delta':[{ '@odata.removed' : {'reason':'changed'}, 'Id':1}]
+ }";
+
+ var requestForPost = new HttpRequestMessage(new HttpMethod("PATCH"), requestUri);
+
+ StringContent stringContent = new StringContent(content: content, encoding: Encoding.UTF8, mediaType: "application/json");
+ requestForPost.Content = stringContent;
+
+ //Act & Assert
+ using (HttpResponseMessage response = await this.Client.SendAsync(requestForPost))
+ {
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ var json = response.Content.ReadAsStringAsync().Result;
+ Assert.Contains("Sql", json);
+ }
+
+
+ }
+
+
+ [Fact]
+ public async Task PatchEmployee_WithAddUpdateAndDelete()
+ {
+ //Arrange
+
+ string requestUri = this.BaseAddress + "/convention/Employees(1)";
+
+ var content = @"{
+ 'Name':'SqlUD',
+ 'Friends@odata.delta':[{ '@odata.removed' : {'reason':'changed'}, 'Id':1},{'Id':2,'Name':'Test3'},{'Id':3,'Name':'Test4'}]
+ }";
+
+ var requestForPost = new HttpRequestMessage(new HttpMethod("PATCH"), requestUri);
+
+ StringContent stringContent = new StringContent(content: content, encoding: Encoding.UTF8, mediaType: "application/json");
+ requestForPost.Content = stringContent;
+
+ //Act & Assert
+ using (HttpResponseMessage response = await this.Client.SendAsync(requestForPost))
+ {
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ var json = response.Content.ReadAsStringAsync().Result;
+ Assert.Contains("SqlUD", json);
+ }
+
+ }
+
+
+ [Fact]
+ public async Task PatchEmployee_WithMultipleUpdatesinOrder1()
+ {
+ //Arrange
+
+ string requestUri = this.BaseAddress + "/convention/Employees(1)";
+
+ var content = @"{
+ 'Name':'SqlMU' ,
+ 'Friends@odata.delta':[{ '@odata.removed' : {'reason':'changed'}, 'Id':1},{'Id':1,'Name':'Test_1'},{'Id':2,'Name':'Test3'},{'Id':3,'Name':'Test4'}]
+ }";
+
+ var requestForPost = new HttpRequestMessage(new HttpMethod("PATCH"), requestUri);
+
+ StringContent stringContent = new StringContent(content: content, encoding: Encoding.UTF8, mediaType: "application/json");
+ requestForPost.Content = stringContent;
+
+ //Act & Assert
+ using (HttpResponseMessage response = await this.Client.SendAsync(requestForPost))
+ {
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ var json = response.Content.ReadAsStringAsync().Result;
+ Assert.Contains("SqlMU", json);
+ }
+
+ }
+
+ [Fact]
+ public async Task PatchEmployee_WithMultipleUpdatesinOrder2()
+ {
+ //Arrange
+
+ string requestUri = this.BaseAddress + "/convention/Employees(1)";
+
+ var content = @"{
+ 'Name':'SqlMU1' ,
+ 'Friends@odata.delta':[{ '@odata.removed' : {'reason':'changed'}, 'Id':1},{'Id':1,'Name':'Test_1'},{'Id':2,'Name':'Test3'},{'Id':3,'Name':'Test4'},{ '@odata.removed' : {'reason':'changed'}, 'Id':1}]
+ }";
+
+ var requestForPost = new HttpRequestMessage(new HttpMethod("PATCH"), requestUri);
+
+ StringContent stringContent = new StringContent(content: content, encoding: Encoding.UTF8, mediaType: "application/json");
+ requestForPost.Content = stringContent;
+
+ //Act & Assert
+ using (HttpResponseMessage response = await this.Client.SendAsync(requestForPost))
+ {
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ var json = response.Content.ReadAsStringAsync().Result;
+ Assert.Contains("SqlMU1", json);
+ }
+
+ }
+
+
+ #endregion
+
+ }
+}
\ No newline at end of file
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/BulkOperation/EFTests/BulkOperationControllerEF.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/BulkOperation/EFTests/BulkOperationControllerEF.cs
new file mode 100644
index 0000000000..918c2c3bc6
--- /dev/null
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/BulkOperation/EFTests/BulkOperationControllerEF.cs
@@ -0,0 +1,196 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.Contracts;
+using System.Linq;
+using Microsoft.AspNet.OData;
+using Microsoft.AspNet.OData.Routing;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Test.E2E.AspNet.OData.BulkOperation;
+using Microsoft.Test.E2E.AspNet.OData.Common.Controllers;
+using Xunit;
+
+namespace Microsoft.Test.E2E.AspNet.OData.BulkInsert
+{
+ public class EmployeesControllerEF : TestODataController
+ {
+ public EmployeesControllerEF()
+ {
+
+ }
+
+ public static List employees;
+ public static List friends;
+
+ public DbSet GenerateData(EmployeeDBContext context)
+ {
+ if (context.Employees.Any())
+ {
+ return context.Employees;
+ }
+
+ var friends = GenerateDataOrders(context);
+
+ employees = new List();
+ employees.Add(new Employee { ID = 1, Name = "Employee1", Friends = friends.Where(x => x.Id == 1 || x.Id == 2).ToList() });
+ employees.Add(new Employee { ID = 2, Name = "Employee2", Friends = friends.Where(x => x.Id == 3 || x.Id == 4).ToList() });
+ employees.Add(new Employee { ID = 3, Name = "Employee3", Friends = friends.Where(x => x.Id == 5 || x.Id == 6).ToList() });
+
+ context.Employees.AddRange(employees);
+
+ context.SaveChanges();
+
+ return context.Employees;
+ }
+
+ public DbSet GenerateDataOrders(EmployeeDBContext context)
+ {
+ if (context.Friends.Any())
+ {
+ return context.Friends;
+ }
+
+ friends = new List();
+ friends.Add(new Friend { Id = 1, Age = 10 , Orders = new List() { new Order { Id = 1, Price = 5 }, new Order { Id = 2, Price = 5 } } });
+ friends.Add(new Friend { Id = 2, Age = 20, Orders = new List() { new Order { Id = 10, Price = 5 }, new Order { Id = 20, Price = 5 } } });
+ friends.Add(new Friend { Id = 3, Age = 30, Orders = new List() { new Order { Id = 3, Price = 5 }, new Order { Id = 4, Price = 5 } } });
+ friends.Add(new Friend { Id = 4, Age = 40, Orders = new List() { new Order { Id = 30, Price = 5 }, new Order { Id = 40, Price = 5 } } });
+ friends.Add(new Friend { Id = 5, Age = 50, Orders = new List() { new Order { Id = 5, Price = 5 }, new Order { Id = 6, Price = 5 } } });
+ friends.Add(new Friend { Id = 6, Age = 60, Orders = new List() { new Order { Id = 50, Price = 5 }, new Order { Id = 60, Price = 5 } } });
+
+ context.Friends.AddRange(friends);
+
+ context.SaveChanges();
+
+ return context.Friends;
+ }
+
+
+ [ODataRoute("Employees")]
+ [HttpPatch]
+ public ITestActionResult PatchEmployees([FromBody] DeltaSet coll)
+ {
+ using (var dbContext = CreateDbContext())
+ {
+ GenerateData(dbContext);
+
+ Assert.NotNull(coll);
+
+ var returncoll = coll.Patch(new APIHandlerFactoryEF(dbContext));
+
+
+ return Ok(returncoll);
+ }
+ }
+
+ private EmployeeDBContext CreateDbContext()
+ {
+ var buiilder = new DbContextOptionsBuilder().UseInMemoryDatabase(Guid.NewGuid().ToString());
+ var dbContext = new EmployeeDBContext(buiilder.Options);
+ return dbContext;
+ }
+
+ [ODataRoute("Employees({key})")]
+ public ITestActionResult Patch(int key, [FromBody] Delta delta)
+ {
+ using (var dbContext = CreateDbContext())
+ {
+ GenerateData(dbContext);
+
+ delta.TrySetPropertyValue("ID", key); // It is the key property, and should not be updated.
+ object obj;
+ delta.TryGetPropertyValue("Friends", out obj);
+
+ var employee = dbContext.Employees.First(x => x.ID == key);
+
+ try
+ {
+ delta.Patch(employee, new APIHandlerFactoryEF(dbContext));
+
+ }
+ catch (ArgumentException ae)
+ {
+ return BadRequest(ae.Message);
+ }
+
+ employee = dbContext.Employees.First(x => x.ID == key);
+
+ ValidateFriends(key, employee);
+
+ return Ok(employee);
+ }
+ }
+
+ private static void ValidateFriends(int key, Employee employee)
+ {
+ if (key == 1 && employee.Name == "SqlUD")
+ {
+ Contract.Assert(employee.Friends.Count == 2);
+ Contract.Assert(employee.Friends[0].Id == 2);
+ Contract.Assert(employee.Friends[1].Id == 3);
+ }
+ else if (key == 1 && employee.Name == "SqlFU")
+ {
+ Contract.Assert(employee.Friends.Count == 3);
+ Contract.Assert(employee.Friends[0].Id == 345);
+ Contract.Assert(employee.Friends[1].Id == 400);
+ Contract.Assert(employee.Friends[2].Id == 900);
+ }
+ else if (key == 1 && employee.Name == "SqlMU")
+ {
+ Contract.Assert(employee.Friends.Count == 3);
+ Contract.Assert(employee.Friends[0].Id == 2);
+ Contract.Assert(employee.Friends[1].Id == 1);
+ Contract.Assert(employee.Friends[1].Name == "Test_1");
+ Contract.Assert(employee.Friends[2].Id == 3);
+ }
+ else if (key == 1 && employee.Name == "SqlMU1")
+ {
+ Contract.Assert(employee.Friends.Count == 2);
+ Contract.Assert(employee.Friends[0].Id == 2);
+ Contract.Assert(employee.Friends[1].Id == 3);
+ }
+ }
+
+ [ODataRoute("Employees({key})/Friends")]
+ [HttpPatch]
+ public ITestActionResult PatchFriends(int key, [FromBody] DeltaSet friendColl)
+ {
+ using (var dbContext = CreateDbContext())
+ {
+ GenerateData(dbContext);
+
+ Employee originalEmployee = dbContext.Employees.SingleOrDefault(c => c.ID == key);
+ Assert.NotNull(originalEmployee);
+
+ var changedObjColl = friendColl.Patch(originalEmployee.Friends);
+
+ return Ok(changedObjColl);
+ }
+ }
+
+ public ITestActionResult Get(int key)
+ {
+ using (var dbContext = CreateDbContext())
+ {
+ var emp = dbContext.Employees.SingleOrDefault(e => e.ID == key);
+ return Ok(emp);
+ }
+ }
+
+ [ODataRoute("Employees({key})/Friends")]
+ public ITestActionResult GetFriends(int key)
+ {
+ using (var dbContext = CreateDbContext())
+ {
+ var emp = dbContext.Employees.SingleOrDefault(e => e.ID == key);
+ return Ok(emp.Friends);
+ }
+ }
+
+
+ }
+}
\ No newline at end of file
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/BulkOperation/EFTests/BulkOperationPatchHandlersEF.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/BulkOperation/EFTests/BulkOperationPatchHandlersEF.cs
new file mode 100644
index 0000000000..c987e3bf9d
--- /dev/null
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/BulkOperation/EFTests/BulkOperationPatchHandlersEF.cs
@@ -0,0 +1,440 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.AspNet.OData;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.Test.E2E.AspNet.OData.BulkInsert;
+
+namespace Microsoft.Test.E2E.AspNet.OData.BulkOperation
+{
+ public class EmployeeDBContext : DbContext
+ {
+ public EmployeeDBContext()
+ {
+
+ }
+
+ public EmployeeDBContext(DbContextOptions options) : base(options)
+ {
+
+ }
+
+ public DbSet Employees { get; set; }
+ public DbSet Friends { get; set; }
+
+ protected override void OnModelCreating(Microsoft.EntityFrameworkCore.ModelBuilder modelBuilder)
+ {
+ modelBuilder.Entity().HasKey(c => c.ID);
+ modelBuilder.Entity().Ignore(c => c.SkillSet);
+ modelBuilder.Entity().Ignore(c => c.NewFriends);
+ modelBuilder.Entity().Ignore(c => c.UnTypedFriends);
+ modelBuilder.Entity().Ignore(c => c.InstanceAnnotations);
+
+ modelBuilder.Entity().Ignore(c => c.InstanceAnnotations);
+ modelBuilder.Entity().Ignore(c => c.InstanceAnnotations);
+
+ modelBuilder.Entity().HasKey(c => c.Id);
+
+ modelBuilder.Entity().Ignore(c => c.Container);
+ modelBuilder.Entity().Ignore(c => c.Container);
+ }
+
+
+ }
+
+ public class APIHandlerFactoryEF: ODataAPIHandlerFactory
+ {
+ EmployeeDBContext dbContext;
+
+ public APIHandlerFactoryEF()
+ {
+
+ }
+
+ public APIHandlerFactoryEF(EmployeeDBContext dbContext)
+ {
+ this.dbContext = dbContext;
+ }
+
+ public override IODataAPIHandler GetHandler(NavigationPath navigationPath)
+ {
+ if (navigationPath != null)
+ {
+ var pathItems = navigationPath.GetNavigationPathItems();
+
+ if (pathItems == null)
+ {
+ switch (navigationPath.NavigationPathName)
+ {
+ case "Employees":
+ case "Employee":
+ return new EmployeeEFPatchHandler(dbContext);
+
+ case "Company":
+ return new CompanyAPIHandler();
+ default:
+ return null;
+ }
+ }
+ }
+
+ return null;
+
+ }
+
+ public class EmployeeEFPatchHandler : ODataAPIHandler
+ {
+ EmployeeDBContext dbContext = null;
+
+ public EmployeeEFPatchHandler(EmployeeDBContext dbContext)
+ {
+ this.dbContext = dbContext;
+ }
+
+ public override ODataAPIResponseStatus TryCreate(IDictionary keyValues, out Employee createdObject, out string errorMessage)
+ {
+ createdObject = null;
+ errorMessage = string.Empty;
+
+ try
+ {
+ createdObject = new Employee();
+ dbContext.Employees.Add(createdObject);
+
+ return ODataAPIResponseStatus.Success;
+ }
+ catch (Exception ex)
+ {
+ errorMessage = ex.Message;
+
+ return ODataAPIResponseStatus.Failure;
+ }
+ }
+
+ public override ODataAPIResponseStatus TryDelete(IDictionary keyValues, out string errorMessage)
+ {
+ errorMessage = string.Empty;
+
+ try
+ {
+ var id = keyValues.First().Value.ToString();
+ var customer = dbContext.Employees.First(x => x.ID == Int32.Parse(id));
+
+ dbContext.Employees.Remove(customer);
+
+ return ODataAPIResponseStatus.Success;
+ }
+ catch (Exception ex)
+ {
+ errorMessage = ex.Message;
+
+ return ODataAPIResponseStatus.Failure;
+ }
+ }
+
+ public override ODataAPIResponseStatus TryGet(IDictionary keyValues, out Employee originalObject, out string errorMessage)
+ {
+ ODataAPIResponseStatus status = ODataAPIResponseStatus.Success;
+ errorMessage = string.Empty;
+ originalObject = null;
+
+ try
+ {
+ var id = keyValues["ID"].ToString();
+ originalObject = dbContext.Employees.First(x => x.ID == Int32.Parse(id));
+
+
+ if (originalObject == null)
+ {
+ status = ODataAPIResponseStatus.NotFound;
+ }
+
+ }
+ catch (Exception ex)
+ {
+ status = ODataAPIResponseStatus.Failure;
+ errorMessage = ex.Message;
+ }
+
+ return status;
+ }
+
+ public override IODataAPIHandler GetNestedHandler(Employee parent, string navigationPropertyName)
+ {
+ switch (navigationPropertyName)
+ {
+ case "Friends":
+ return new FriendEFPatchHandler(parent);
+ case "NewFriends":
+ return new NewFriendEFPatchHandler(parent);
+ default:
+ return null;
+ }
+
+ }
+
+ }
+
+ public class FriendEFPatchHandler : ODataAPIHandler
+ {
+ Employee employee;
+ public FriendEFPatchHandler(Employee employee)
+ {
+ this.employee = employee;
+ }
+
+ public override ODataAPIResponseStatus TryCreate(IDictionary keyValues, out Friend createdObject, out string errorMessage)
+ {
+ createdObject = null;
+ errorMessage = string.Empty;
+
+ try
+ {
+ createdObject = new Friend();
+ employee.Friends.Add(createdObject);
+
+ return ODataAPIResponseStatus.Success;
+ }
+ catch (Exception ex)
+ {
+ errorMessage = ex.Message;
+
+ return ODataAPIResponseStatus.Failure;
+ }
+ }
+
+ public override ODataAPIResponseStatus TryDelete(IDictionary keyValues, out string errorMessage)
+ {
+ errorMessage = string.Empty;
+
+ try
+ {
+ var id = keyValues.First().Value.ToString();
+ var friend = employee.Friends.First(x => x.Id == Int32.Parse(id));
+
+ employee.Friends.Remove(friend);
+
+ return ODataAPIResponseStatus.Success;
+ }
+ catch (Exception ex)
+ {
+ errorMessage = ex.Message;
+
+ return ODataAPIResponseStatus.Failure;
+ }
+ }
+
+ public override ODataAPIResponseStatus TryGet(IDictionary keyValues, out Friend originalObject, out string errorMessage)
+ {
+ ODataAPIResponseStatus status = ODataAPIResponseStatus.Success;
+ errorMessage = string.Empty;
+ originalObject = null;
+
+ try
+ {
+ var id = keyValues["Id"].ToString();
+ if (employee.Friends == null)
+ {
+ status = ODataAPIResponseStatus.NotFound;
+ }
+ else
+ {
+ originalObject = employee.Friends.FirstOrDefault(x => x.Id == Int32.Parse(id));
+ }
+
+
+ if (originalObject == null)
+ {
+ status = ODataAPIResponseStatus.NotFound;
+ }
+
+ }
+ catch (Exception ex)
+ {
+ status = ODataAPIResponseStatus.Failure;
+ errorMessage = ex.Message;
+ }
+
+ return status;
+ }
+
+ public override IODataAPIHandler GetNestedHandler(Friend parent, string navigationPropertyName)
+ {
+ return new OrderEFPatchHandler(parent);
+ }
+
+ }
+
+
+ public class NewFriendEFPatchHandler : ODataAPIHandler
+ {
+ Employee employee;
+ public NewFriendEFPatchHandler(Employee employee)
+ {
+ this.employee = employee;
+ }
+
+ public override ODataAPIResponseStatus TryCreate(IDictionary keyValues, out NewFriend createdObject, out string errorMessage)
+ {
+ createdObject = null;
+ errorMessage = string.Empty;
+
+ try
+ {
+ createdObject = new NewFriend();
+ employee.NewFriends.Add(createdObject);
+
+ return ODataAPIResponseStatus.Success;
+ }
+ catch (Exception ex)
+ {
+ errorMessage = ex.Message;
+
+ return ODataAPIResponseStatus.Failure;
+ }
+ }
+
+ public override ODataAPIResponseStatus TryDelete(IDictionary keyValues, out string errorMessage)
+ {
+ errorMessage = string.Empty;
+
+ try
+ {
+ var id = keyValues.First().Value.ToString();
+ var friend = employee.NewFriends.First(x => x.Id == Int32.Parse(id));
+
+ employee.NewFriends.Remove(friend);
+
+ return ODataAPIResponseStatus.Success;
+ }
+ catch (Exception ex)
+ {
+ errorMessage = ex.Message;
+
+ return ODataAPIResponseStatus.Failure;
+ }
+ }
+
+ public override ODataAPIResponseStatus TryGet(IDictionary keyValues, out NewFriend originalObject, out string errorMessage)
+ {
+ ODataAPIResponseStatus status = ODataAPIResponseStatus.Success;
+ errorMessage = string.Empty;
+ originalObject = null;
+
+ try
+ {
+ var id = keyValues["Id"].ToString();
+ originalObject = employee.NewFriends.First(x => x.Id == Int32.Parse(id));
+
+
+ if (originalObject == null)
+ {
+ status = ODataAPIResponseStatus.NotFound;
+ }
+
+ }
+ catch (Exception ex)
+ {
+ status = ODataAPIResponseStatus.Failure;
+ errorMessage = ex.Message;
+ }
+
+ return status;
+ }
+
+ public override IODataAPIHandler GetNestedHandler(NewFriend parent, string navigationPropertyName)
+ {
+ return null;
+ }
+
+ }
+
+
+
+ public class OrderEFPatchHandler : ODataAPIHandler
+ {
+ Friend friend;
+ public OrderEFPatchHandler(Friend friend)
+ {
+ this.friend = friend;
+ }
+
+ public override ODataAPIResponseStatus TryCreate(IDictionary keyValues, out Order createdObject, out string errorMessage)
+ {
+ createdObject = null;
+ errorMessage = string.Empty;
+
+ try
+ {
+ createdObject = new Order();
+ friend.Orders.Add(createdObject);
+
+ return ODataAPIResponseStatus.Success;
+ }
+ catch (Exception ex)
+ {
+ errorMessage = ex.Message;
+
+ return ODataAPIResponseStatus.Failure;
+ }
+ }
+
+ public override ODataAPIResponseStatus TryDelete(IDictionary keyValues, out string errorMessage)
+ {
+ errorMessage = string.Empty;
+
+ try
+ {
+ var id = keyValues.First().Value.ToString();
+ var order = friend.Orders.First(x => x.Id == Int32.Parse(id));
+
+ friend.Orders.Remove(order);
+
+ return ODataAPIResponseStatus.Success;
+ }
+ catch (Exception ex)
+ {
+ errorMessage = ex.Message;
+
+ return ODataAPIResponseStatus.Failure;
+ }
+ }
+
+ public override ODataAPIResponseStatus TryGet(IDictionary keyValues, out Order originalObject, out string errorMessage)
+ {
+ ODataAPIResponseStatus status = ODataAPIResponseStatus.Success;
+ errorMessage = string.Empty;
+ originalObject = null;
+
+ try
+ {
+ var id = keyValues["Id"].ToString();
+ originalObject = friend.Orders.First(x => x.Id == Int32.Parse(id));
+
+
+ if (originalObject == null)
+ {
+ status = ODataAPIResponseStatus.NotFound;
+ }
+
+ }
+ catch (Exception ex)
+ {
+ status = ODataAPIResponseStatus.Failure;
+ errorMessage = ex.Message;
+ }
+
+ return status;
+ }
+
+ public override IODataAPIHandler GetNestedHandler(Order parent, string navigationPropertyName)
+ {
+ throw new NotImplementedException();
+ }
+ }
+
+ }
+}
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/ConcurrentQuery/ConcurrentQueryController.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/ConcurrentQuery/ConcurrentQueryController.cs
index 0bff8af3ea..10b16bf6ee 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/ConcurrentQuery/ConcurrentQueryController.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/ConcurrentQuery/ConcurrentQueryController.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Linq;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/ConcurrentQuery/ConcurrentQueryEdmModel.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/ConcurrentQuery/ConcurrentQueryEdmModel.cs
index 80785726eb..be5832fe2c 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/ConcurrentQuery/ConcurrentQueryEdmModel.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/ConcurrentQuery/ConcurrentQueryEdmModel.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.OData.Edm;
using Microsoft.Test.E2E.AspNet.OData.Common.Execution;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/ConcurrentQuery/ConcurrentQueryODataModel.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/ConcurrentQuery/ConcurrentQueryODataModel.cs
index 44e0fc328f..aae3b9095f 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/ConcurrentQuery/ConcurrentQueryODataModel.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/ConcurrentQuery/ConcurrentQueryODataModel.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/ConcurrentQuery/ConcurrentQueryTests.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/ConcurrentQuery/ConcurrentQueryTests.cs
index 312ab0f8cf..b5a32ad6a3 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/ConcurrentQuery/ConcurrentQueryTests.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/ConcurrentQuery/ConcurrentQueryTests.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/DependencyInjection/CustomizeSkipTokenImplementationTest.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/DependencyInjection/CustomizeSkipTokenImplementationTest.cs
index 406a4cbc60..2feb47a7f8 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/DependencyInjection/CustomizeSkipTokenImplementationTest.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/DependencyInjection/CustomizeSkipTokenImplementationTest.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/Endpoint/EndpointController.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/Endpoint/EndpointController.cs
index 42a7e85806..f12fa6f3f6 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/Endpoint/EndpointController.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/Endpoint/EndpointController.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/Endpoint/EndpointDbContext.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/Endpoint/EndpointDbContext.cs
index 82a2e36f7c..e221083e48 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/Endpoint/EndpointDbContext.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/Endpoint/EndpointDbContext.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.EntityFrameworkCore;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/Endpoint/EndpointEfCoreTests.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/Endpoint/EndpointEfCoreTests.cs
index 56056873aa..d3a63e7210 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/Endpoint/EndpointEfCoreTests.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/Endpoint/EndpointEfCoreTests.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Linq;
@@ -275,4 +279,3 @@ public async Task CanReadDataInBatchUsingEndpointRouting()
}
}
}
-
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/Endpoint/EndpointRouteConfiguration.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/Endpoint/EndpointRouteConfiguration.cs
index 121b198990..ec96019cd3 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/Endpoint/EndpointRouteConfiguration.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/Endpoint/EndpointRouteConfiguration.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/Endpoint/EndpointTestBase.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/Endpoint/EndpointTestBase.cs
index 8fdb0b903b..b854575b16 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/Endpoint/EndpointTestBase.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/Endpoint/EndpointTestBase.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Net.Http;
using Xunit;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/Endpoint/EndpointTestFixture.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/Endpoint/EndpointTestFixture.cs
index 6eef9e87cb..c9ffe9191d 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/Endpoint/EndpointTestFixture.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/Endpoint/EndpointTestFixture.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Net;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/Endpoint/EndpointTestModel.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/Endpoint/EndpointTestModel.cs
index 591b51c115..503deff434 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/Endpoint/EndpointTestModel.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/Endpoint/EndpointTestModel.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/Microsoft.Test.E2E.AspNetCore3x.OData.csproj b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/Microsoft.Test.E2E.AspNetCore3x.OData.csproj
index 8baade2685..397cc219ef 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/Microsoft.Test.E2E.AspNetCore3x.OData.csproj
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/Microsoft.Test.E2E.AspNetCore3x.OData.csproj
@@ -27,7 +27,8 @@
-
+
+
@@ -1662,6 +1663,18 @@
Validation\DeltaOfTValidationTests.cs
+
+ BulkOperation\BulkInsertDataModel.cs
+
+
+ BulkOperation\BulkInsertEdmModel.cs
+
+
+ BulkOperation\BulkInsertController.cs
+
+
+ BulkOperation\BulkOperationPatchHandlers.cs
+
@@ -1675,4 +1688,5 @@
+
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/NestedPaths/NestedPathEFTests.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/NestedPaths/NestedPathEFTests.cs
new file mode 100644
index 0000000000..14cb6f6661
--- /dev/null
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/NestedPaths/NestedPathEFTests.cs
@@ -0,0 +1,380 @@
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
+
+using System.Collections.Generic;
+using System.Data.Entity;
+using System.Linq;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Threading.Tasks;
+using Microsoft.AspNet.OData;
+using Microsoft.AspNet.OData.Extensions;
+using Microsoft.AspNet.OData.Routing;
+using Microsoft.OData.Edm;
+using Microsoft.Test.E2E.AspNet.OData.Common;
+using Microsoft.Test.E2E.AspNet.OData.Common.Controllers;
+using Microsoft.Test.E2E.AspNet.OData.Common.Execution;
+using Newtonsoft.Json.Linq;
+using Xunit;
+
+namespace Microsoft.Test.E2E.AspNet.OData.NestedPaths
+{
+ public class NestedPathEFTests : WebHostTestBase
+ {
+ public NestedPathEFTests(WebHostTestFixture fixture)
+ :base(fixture)
+ {
+ }
+
+ protected override void UpdateConfiguration(WebRouteConfiguration configuration)
+ {
+ configuration.AddControllers(
+ typeof(EFCustomersController),
+ typeof(EFOrdersController),
+ typeof(EFProductsController));
+ configuration.JsonReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
+ configuration.Count().Filter().OrderBy().Expand().MaxTop(null).Select();
+ configuration.MapODataServiceRoute("nestedpaths", "nestedpaths", GetEdmModel(configuration));
+ }
+
+ private static IEdmModel GetEdmModel(WebRouteConfiguration configuration)
+ {
+ var builder = configuration.CreateConventionModelBuilder();
+
+ builder.EntitySet("EFCustomers");
+ builder.EntitySet("EFProducts");
+ builder.EntitySet("EFOrders");
+ builder.Action("ResetDataSource-Customer");
+ builder.Action("ResetDataSource-Order");
+ builder.Action("ResetDataSource-Product");
+
+ return builder.GetEdmModel();
+ }
+
+ [Fact]
+ public async Task QueriesDataCorrectlyBasedOnNestedPath()
+ {
+ // Arrange
+ await RestoreData("-Customer");
+ string queryUrl = GetFullUrl("EFCustomers(2)/Orders(6)/Products");
+ HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, queryUrl);
+ request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/json;odata.metadata=none"));
+ HttpClient client = new HttpClient();
+ HttpResponseMessage response;
+
+ // Act
+ response = await client.SendAsync(request);
+
+ // Assert
+ Assert.NotNull(response);
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ Assert.NotNull(response.Content);
+
+ var responseObject = JObject.Parse(await response.Content.ReadAsStringAsync());
+ var result = responseObject["value"] as JArray;
+ JsonAssert.ArrayLength(2, "value", responseObject);
+
+ AssertJsonProduct(result[0] as JObject, 6, "Product6");
+ AssertJsonProduct(result[1] as JObject, 7, "Product7");
+ }
+
+ [Fact]
+ public async Task QueryOptionsAreAppliedToResultIfEnableQueryProvided()
+ {
+ // Arrange
+ await RestoreData("-Order");
+ string queryUrl = GetFullUrl("EFOrders(1)?$expand=Products");
+ HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, queryUrl);
+ request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/json;odata.metadata=none"));
+ HttpClient client = new HttpClient();
+ HttpResponseMessage response;
+
+ // Act
+ response = await client.SendAsync(request);
+
+ // Assert
+ Assert.NotNull(response);
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ Assert.NotNull(response.Content);
+
+ var responseObject = JObject.Parse(await response.Content.ReadAsStringAsync());
+ var products = responseObject["Products"] as JArray;
+ JsonAssert.ArrayLength(2, "Products", responseObject);
+
+ AssertJsonProduct(products[0] as JObject, 1, "Product1");
+ AssertJsonProduct(products[1] as JObject, 2, "Product2");
+ }
+
+ [Fact]
+ public async Task SupportsComplexProperties()
+ {
+ // Arrange
+ await RestoreData("-Customer");
+ string queryUrl = GetFullUrl("EFCustomers(1)/HomeAddress");
+ HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, queryUrl);
+ request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/json;odata.metadata=none"));
+ HttpClient client = new HttpClient();
+ HttpResponseMessage response;
+
+ // Act
+ response = await client.SendAsync(request);
+
+ // Assert
+ Assert.NotNull(response);
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ Assert.NotNull(response.Content);
+
+ var responseObject = JObject.Parse(await response.Content.ReadAsStringAsync());
+ AssertJsonAddress(responseObject, "City1", "Street1");
+ }
+
+ [Fact]
+ public async Task SupportsNavigationProperties()
+ {
+ // Arrange
+ await RestoreData("-Customer");
+ string queryUrl = GetFullUrl("EFCustomers(1)/FavoriteProduct");
+ HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, queryUrl);
+ request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/json;odata.metadata=none"));
+ HttpClient client = new HttpClient();
+ HttpResponseMessage response;
+
+ // Act
+ response = await client.SendAsync(request);
+
+ // Assert
+ Assert.NotNull(response);
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ Assert.NotNull(response.Content);
+
+ var responseObject = JObject.Parse(await response.Content.ReadAsStringAsync());
+ AssertJsonProduct(responseObject, 1, "Product1");
+ }
+
+ [Theory]
+ [InlineData("EFCustomers(4)/FavoriteProduct")]
+ [InlineData("EFCustomers(4)/Favoriteproduct/Name")]
+ [InlineData("EFCustomers(4)/HomeAddress/City")]
+ public async Task Returns404IfAccessingNullProperties(string path)
+ {
+ // Arrange
+ await RestoreData("-Customer");
+ string queryUrl = GetFullUrl(path);
+ HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, queryUrl);
+ request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/json;odata.metadata=none"));
+ HttpClient client = new HttpClient();
+ HttpResponseMessage response;
+
+ // Act
+ response = await client.SendAsync(request);
+
+ // Assert
+ Assert.NotNull(response);
+ Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
+ }
+
+ private string GetFullUrl(string relativeUrl)
+ {
+ return $"{BaseAddress}/nestedpaths/{relativeUrl}";
+ }
+
+ private void AssertJsonProduct(JObject product, int id, string name)
+ {
+ Assert.NotNull(product);
+ Assert.Equal(id, product["Id"].ToObject());
+ Assert.Equal(name, product["Name"].ToObject());
+ }
+
+ private void AssertJsonAddress(JObject address, string city, string street)
+ {
+ Assert.NotNull(address);
+ Assert.Equal(city, address["City"].ToObject());
+ Assert.Equal(street, address["Street"].ToObject());
+ }
+
+ private async Task RestoreData(string suffix)
+ {
+ string requestUri = GetFullUrl($"ResetDataSource{suffix}");
+ HttpClient client = new HttpClient();
+ HttpResponseMessage response = await client.GetAsync(requestUri);
+ response.EnsureSuccessStatusCode();
+ }
+ }
+
+
+ public static class Database
+ {
+ public static void RestoreData(SampleContext db)
+ {
+ db.Database.Delete();
+ GenerateData(db);
+ }
+
+ public static void GenerateData(SampleContext db)
+ {
+ for (int i = 0; i < 10; i++)
+ {
+ int id = i + 1;
+ db.Products.Add(new EFProduct
+ {
+ Id = id,
+ Name = $"Product{id}"
+ });
+ }
+
+ db.SaveChanges();
+
+ for (int i = 0; i < 9; i++)
+ {
+ int id = i + 1;
+ db.Orders.Add(new EFOrder
+ {
+ Id = id,
+ // link order 1 to product 1 and 2, order 2 to product 2 and 3, etc.
+ Products = db.Products.OrderBy(p => p.Id).Skip(i).Take(2).ToList()
+ });
+ }
+
+ db.SaveChanges();
+
+ for (int i = 0; i < 3; i++)
+ {
+ int id = i + 1;
+ db.Customers.Add(new EFCustomer
+ {
+ Id = id,
+ Name = $"Customer{id}",
+ HomeAddress = new EFAddress { City = $"City{id}", Street = $"Street{id}" },
+ FavoriteProduct = db.Products.Where(p => p.Id == id).FirstOrDefault(),
+ // link customer 1 to orders 1 to 3, customer 2 to orders 4 to 6, etc.
+ Orders = db.Orders.OrderBy(o => o.Id).Skip(i * 3).Take(3).ToList()
+ });
+ }
+
+ db.Customers.Add(new EFCustomer
+ {
+ Id = 4,
+ Name = "Customer4",
+ HomeAddress = new EFAddress(),
+ FavoriteProduct = null,
+ Orders = new List()
+ });
+
+ db.SaveChanges();
+ }
+ }
+
+ public class SampleContext : DbContext
+ {
+ public static string ConnectionString = @"Data Source=(LocalDb)\MSSQLLocalDB;Integrated Security=True;Initial Catalog=NestedPathsTests";
+
+ public SampleContext()
+ : base(ConnectionString)
+ {
+ }
+
+ protected override void OnModelCreating(DbModelBuilder modelBuilder)
+ {
+ modelBuilder.Entity().HasMany(o => o.Products).WithMany();
+ modelBuilder.Entity().HasMany(c => c.Orders).WithMany();
+ base.OnModelCreating(modelBuilder);
+ }
+
+ public DbSet Customers { get; set; }
+
+ public DbSet Orders { get; set; }
+
+ public DbSet Products { get; set; }
+ }
+
+
+ public class EFCustomersController: TestODataController
+ {
+ SampleContext _db = new SampleContext();
+
+ [EnableNestedPaths]
+ public IQueryable Get()
+ {
+ return _db.Customers;
+ }
+
+ [HttpGet]
+ [ODataRoute("ResetDataSource-Customer")]
+ public ITestActionResult ResetDataSource()
+ {
+ Database.RestoreData(_db);
+ return Ok();
+ }
+ }
+
+ public class EFOrdersController: TestODataController
+ {
+ SampleContext _db = new SampleContext();
+
+ [EnableNestedPaths]
+ [EnableQuery]
+ public IQueryable Get()
+ {
+ return _db.Orders;
+ }
+
+ [HttpGet]
+ [ODataRoute("ResetDataSource-Order")]
+ public ITestActionResult ResetDataSource()
+ {
+ Database.RestoreData(_db);
+ return Ok();
+ }
+ }
+
+ public class EFProductsController: TestODataController
+ {
+ SampleContext _db = new SampleContext();
+
+ [EnableNestedPaths]
+ public IQueryable Get()
+ {
+ return _db.Products;
+ }
+
+ [HttpGet]
+ [ODataRoute("ResetDataSource-Product")]
+ public ITestActionResult ResetDataSource()
+ {
+ Database.RestoreData(_db);
+ return Ok();
+ }
+ }
+
+ public class EFCustomer
+ {
+ public int Id { get; set; }
+ public string Name { get; set; }
+ public virtual EFAddress HomeAddress { get; set; }
+ public virtual EFProduct FavoriteProduct { get; set; }
+ public virtual List Orders { get; set; }
+ }
+
+ public class EFAddress
+ {
+ public string City { get; set; }
+ public string Street { get; set; }
+ }
+
+ public class EFOrder
+ {
+ public int Id { get; set; }
+ public virtual List Products { get; set; }
+ }
+
+ public class EFProduct
+ {
+ public int Id { get; set; }
+ public string Name { get; set; }
+ }
+}
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/NestedPaths/NestedPathsTests.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/NestedPaths/NestedPathsTests.cs
new file mode 100644
index 0000000000..23cf207769
--- /dev/null
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/NestedPaths/NestedPathsTests.cs
@@ -0,0 +1,544 @@
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
+
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Threading.Tasks;
+using Microsoft.AspNet.OData;
+using Microsoft.AspNet.OData.Extensions;
+using Microsoft.OData.Edm;
+using Microsoft.Test.E2E.AspNet.OData.Common;
+using Microsoft.Test.E2E.AspNet.OData.Common.Execution;
+using Newtonsoft.Json.Linq;
+using Xunit;
+
+namespace Microsoft.Test.E2E.AspNet.OData.NestedPaths
+{
+ public class NestedPathsTests: WebHostTestBase
+ {
+ public NestedPathsTests(WebHostTestFixture fixture)
+ : base(fixture)
+ { }
+
+ protected override void UpdateConfiguration(WebRouteConfiguration configuration)
+ {
+ configuration.AddControllers(
+ typeof(CustomersController),
+ typeof(TopCustomerController));
+ configuration.JsonReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
+ configuration.Count().Filter().OrderBy().Expand().MaxTop(null).Select();
+ configuration.MapODataServiceRoute("nestedpaths", "nestedpaths", GetEdmModel(configuration));
+ }
+
+ private static IEdmModel GetEdmModel(WebRouteConfiguration configuration)
+ {
+ var builder = configuration.CreateConventionModelBuilder();
+
+ builder.EntitySet("Customers");
+ builder.Singleton("TopCustomer");
+
+ return builder.GetEdmModel();
+ }
+
+ [Fact]
+ public async Task FetchingEntitySetWorks()
+ {
+ // Arrange
+ string queryUrl = string.Format("{0}/nestedpaths/Customers", BaseAddress);
+ HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, queryUrl);
+ request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/json;odata.metadata=minimal"));
+ HttpClient client = new HttpClient();
+
+ // Act
+ HttpResponseMessage response = await client.SendAsync(request);
+
+ // Assert
+ Assert.NotNull(response);
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+
+ Assert.NotNull(response.Content);
+ JObject result = JObject.Parse(await response.Content.ReadAsStringAsync());
+ Assert.NotNull(result);
+
+ JsonAssert.ArrayLength(10, "value", result);
+ JArray customers = (JArray)result["value"];
+
+ for (int i = 0; i < 10; i++)
+ {
+ Assert.Equal(i, customers[i]["Id"].ToObject());
+ Assert.Equal($"customer{i}", customers[i]["Name"].ToObject());
+ AssertJsonAddress(customers[i]["HomeAddress"] as JObject, $"City{i}", $"Street{i}");
+ JsonAssert.ArrayLength(2, "OtherAddresses", customers[i] as JObject);
+ AssertJsonAddress(customers[i]["OtherAddresses"][0] as JObject, $"CityA{i}", $"StreetA{i}");
+ AssertJsonAddress(customers[i]["OtherAddresses"][1] as JObject, $"CityB{i}", $"StreetB{i}");
+ }
+ }
+
+ [Fact]
+ public async Task FetchingEntityWorks()
+ {
+ // Arrange
+ string queryUrl = string.Format("{0}/nestedpaths/Customers(2)", BaseAddress);
+ HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, queryUrl);
+ request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/json;odata.metadata=minimal"));
+ HttpClient client = new HttpClient();
+
+ // Act
+ HttpResponseMessage response = await client.SendAsync(request);
+
+ // Assert
+ Assert.NotNull(response);
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+
+ Assert.NotNull(response.Content);
+ JObject customer = JObject.Parse(await response.Content.ReadAsStringAsync());
+ Assert.NotNull(customer);
+
+ Assert.Equal(2, customer["Id"].ToObject());
+ Assert.Equal("customer2", customer["Name"].ToObject());
+ AssertJsonAddress(customer["HomeAddress"] as JObject, "City2", "Street2");
+ JsonAssert.ArrayLength(2, "OtherAddresses", customer);
+ AssertJsonAddress(customer["OtherAddresses"][0] as JObject, "CityA2", "StreetA2");
+ AssertJsonAddress(customer["OtherAddresses"][1] as JObject, "CityB2", "StreetB2");
+ }
+
+ [Fact]
+ public async Task FetchingEntityPrimitivePropertyWorks()
+ {
+ // Arrange
+ string queryUrl = string.Format("{0}/nestedpaths/Customers(2)/Name", BaseAddress);
+ HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, queryUrl);
+ request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/json;odata.metadata=minimal"));
+ HttpClient client = new HttpClient();
+
+ // Act
+ HttpResponseMessage response = await client.SendAsync(request);
+
+ // Assert
+ Assert.NotNull(response);
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+
+ Assert.NotNull(response.Content);
+ JObject name = JObject.Parse(await response.Content.ReadAsStringAsync());
+ Assert.NotNull(name);
+
+ Assert.Equal("customer2", name["value"].ToObject());
+ }
+
+ [Fact]
+ public async Task FetchingPrimitiveCollectionPropertyWorks()
+ {
+ // Arrange
+ string queryUrl = string.Format("{0}/nestedpaths/Customers(1)/Hobbies", BaseAddress);
+ HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, queryUrl);
+ request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/json;odata.metadata=minimal"));
+ HttpClient client = new HttpClient();
+
+ // Act
+ HttpResponseMessage response = await client.SendAsync(request);
+
+ // Assert
+ Assert.NotNull(response);
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+
+ Assert.NotNull(response.Content);
+ JObject result = JObject.Parse(await response.Content.ReadAsStringAsync());
+ Assert.NotNull(result);
+
+ JsonAssert.ArrayLength(2, "value", result);
+ JArray hobbies = (JArray)result["value"];
+
+ Assert.Equal("Running1", hobbies[0].ToObject());
+ Assert.Equal("Swimming1", hobbies[1].ToObject());
+ }
+
+ [Fact]
+ public async Task FetchingComplexPropertyWorks()
+ {
+ // Arrange
+ string queryUrl = string.Format("{0}/nestedpaths/Customers(2)/HomeAddress", BaseAddress);
+ HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, queryUrl);
+ request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/json;odata.metadata=minimal"));
+ HttpClient client = new HttpClient();
+
+ // Act
+ HttpResponseMessage response = await client.SendAsync(request);
+
+ // Assert
+ Assert.NotNull(response);
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+
+ Assert.NotNull(response.Content);
+ JObject address = JObject.Parse(await response.Content.ReadAsStringAsync());
+ AssertJsonAddress(address, "City2", "Street2");
+ }
+
+ [Fact]
+ public async Task FetchingPropertyOfComplexPropertyWorks()
+ {
+ // Arrange
+ string queryUrl = string.Format("{0}/nestedpaths/Customers(3)/HomeAddress/Street", BaseAddress);
+ HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, queryUrl);
+ request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/json;odata.metadata=minimal"));
+ HttpClient client = new HttpClient();
+
+ // Act
+ HttpResponseMessage response = await client.SendAsync(request);
+
+ // Assert
+ Assert.NotNull(response);
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+
+ Assert.NotNull(response.Content);
+ JObject street = JObject.Parse(await response.Content.ReadAsStringAsync());
+ Assert.NotNull(street);
+
+ Assert.Equal("Street3", street["value"].ToObject());
+ }
+
+ [Fact]
+ public async Task FetchingComplexCollectionPropertyWorks()
+ {
+ // Arrange
+ string queryUrl = string.Format("{0}/nestedpaths/Customers(1)/OtherAddresses", BaseAddress);
+ HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, queryUrl);
+ request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/json;odata.metadata=minimal"));
+ HttpClient client = new HttpClient();
+
+ // Act
+ HttpResponseMessage response = await client.SendAsync(request);
+
+ // Assert
+ Assert.NotNull(response);
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+
+ Assert.NotNull(response.Content);
+ JObject result = JObject.Parse(await response.Content.ReadAsStringAsync());
+ Assert.NotNull(result);
+
+ JsonAssert.ArrayLength(2, "value", result);
+ JArray addresses = (JArray)result["value"];
+
+ AssertJsonAddress(addresses[0] as JObject, "CityA1", "StreetA1");
+ AssertJsonAddress(addresses[1] as JObject, "CityB1", "StreetB1");
+ }
+
+ [Fact]
+ public async Task FetchingNavigationPropertyWorks()
+ {
+ // Arrange
+ string queryUrl = string.Format("{0}/nestedpaths/Customers(2)/FavoriteProduct", BaseAddress);
+ HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, queryUrl);
+ request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/json;odata.metadata=minimal"));
+ HttpClient client = new HttpClient();
+
+ // Act
+ HttpResponseMessage response = await client.SendAsync(request);
+
+ // Assert
+ Assert.NotNull(response);
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+
+ Assert.NotNull(response.Content);
+ JObject product = JObject.Parse(await response.Content.ReadAsStringAsync());
+ AssertJsonProduct(product, 2, "Product2");
+ }
+
+ [Fact]
+ public async Task FetchingPropertyOfNavigationPropertyWorks()
+ {
+ // Arrange
+ string queryUrl = string.Format("{0}/nestedpaths/Customers(2)/FavoriteProduct/Name", BaseAddress);
+ HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, queryUrl);
+ request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/json;odata.metadata=minimal"));
+ HttpClient client = new HttpClient();
+
+ // Act
+ HttpResponseMessage response = await client.SendAsync(request);
+
+ // Assert
+ // Assert
+ Assert.NotNull(response);
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+
+ Assert.NotNull(response.Content);
+ JObject name = JObject.Parse(await response.Content.ReadAsStringAsync());
+ Assert.NotNull(name);
+
+ Assert.Equal("Product2", name["value"].ToObject());
+ }
+
+ [Fact]
+ public async Task FetchingCollectionNavigationPropertyWorks()
+ {
+ // Arrange
+ string queryUrl = string.Format("{0}/nestedpaths/Customers(1)/Products", BaseAddress);
+ HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, queryUrl);
+ request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/json;odata.metadata=minimal"));
+ HttpClient client = new HttpClient();
+
+ // Act
+ HttpResponseMessage response = await client.SendAsync(request);
+
+ // Assert
+ Assert.NotNull(response);
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+
+ Assert.NotNull(response.Content);
+ JObject result = JObject.Parse(await response.Content.ReadAsStringAsync());
+ Assert.NotNull(result);
+
+ JsonAssert.ArrayLength(2, "value", result);
+ JArray products = (JArray)result["value"];
+
+ AssertJsonProduct(products[0] as JObject, 101, "Product101");
+ AssertJsonProduct(products[1] as JObject, 102, "Product102");
+ }
+
+ [Fact]
+ public async Task FetchingEntityFromNavigationPropertyWorks()
+ {
+ // Arrange
+ string queryUrl = string.Format("{0}/nestedpaths/Customers(2)/Products(102)", BaseAddress);
+ HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, queryUrl);
+ request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/json;odata.metadata=minimal"));
+ HttpClient client = new HttpClient();
+
+ // Act
+ HttpResponseMessage response = await client.SendAsync(request);
+
+ // Assert
+ Assert.NotNull(response);
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+
+ Assert.NotNull(response.Content);
+ JObject product = JObject.Parse(await response.Content.ReadAsStringAsync());
+ AssertJsonProduct(product, 102, "Product102");
+ }
+
+ [Fact]
+ public async Task FetchingPropertyOfEntityFromCollectionNavigationPropertyWorks()
+ {
+ // Arrange
+ string queryUrl = string.Format("{0}/nestedpaths/Customers(2)/Products(103)/Name", BaseAddress);
+ HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, queryUrl);
+ request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/json;odata.metadata=minimal"));
+ HttpClient client = new HttpClient();
+
+ // Act
+ HttpResponseMessage response = await client.SendAsync(request);
+
+ // Assert
+ // Assert
+ Assert.NotNull(response);
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+
+ Assert.NotNull(response.Content);
+ JObject name = JObject.Parse(await response.Content.ReadAsStringAsync());
+ Assert.NotNull(name);
+
+ Assert.Equal("Product103", name["value"].ToObject());
+ }
+
+ [Fact]
+ public async Task FetchingSingletonWorks()
+ {
+ // Arrange
+ string queryUrl = string.Format("{0}/nestedpaths/TopCustomer", BaseAddress);
+ HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, queryUrl);
+ request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/json;odata.metadata=minimal"));
+ HttpClient client = new HttpClient();
+
+ // Act
+ HttpResponseMessage response = await client.SendAsync(request);
+
+ // Assert
+ Assert.NotNull(response);
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+
+ Assert.NotNull(response.Content);
+ JObject customer = JObject.Parse(await response.Content.ReadAsStringAsync());
+ Assert.NotNull(customer);
+
+ Assert.Equal(1, customer["Id"].ToObject());
+ Assert.Equal("customer1", customer["Name"].ToObject());
+ AssertJsonAddress(customer["HomeAddress"] as JObject, "City1", "Street1");
+ JsonAssert.ArrayLength(2, "OtherAddresses", customer);
+ AssertJsonAddress(customer["OtherAddresses"][0] as JObject, "CityA1", "StreetA1");
+ AssertJsonAddress(customer["OtherAddresses"][1] as JObject, "CityB1", "StreetB1");
+ }
+
+ [Fact]
+ public async Task NavigatingFromSingletonWorks()
+ {
+ // Arrange
+ string queryUrl = string.Format("{0}/nestedpaths/TopCustomer/Products(101)/Name", BaseAddress);
+ HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, queryUrl);
+ request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/json;odata.metadata=minimal"));
+ HttpClient client = new HttpClient();
+
+ // Act
+ HttpResponseMessage response = await client.SendAsync(request);
+
+ // Assert
+ Assert.NotNull(response);
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+
+ Assert.NotNull(response.Content);
+ JObject name = JObject.Parse(await response.Content.ReadAsStringAsync());
+ Assert.NotNull(name);
+
+ Assert.Equal("Product101", name["value"].ToObject());
+ }
+
+ [Fact]
+ public async Task DollarValueWorks()
+ {
+ // Arrange
+ string queryUrl = string.Format("{0}/nestedpaths/Customers(2)/Name/$value", BaseAddress);
+ HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, queryUrl);
+ request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("text/plain"));
+ HttpClient client = new HttpClient();
+
+ // Act
+ HttpResponseMessage response = await client.SendAsync(request);
+
+ // Assert
+ Assert.NotNull(response);
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+
+ Assert.NotNull(response.Content);
+ string name = await response.Content.ReadAsStringAsync();
+
+ Assert.Equal("customer2", name);
+ }
+
+ [Fact]
+ public async Task DollarCountWorks()
+ {
+ // Arrange
+ string queryUrl = string.Format("{0}/nestedpaths/Customers(2)/Products/$count", BaseAddress);
+ HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, queryUrl);
+ request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("text/plain"));
+ HttpClient client = new HttpClient();
+
+ // Act
+ HttpResponseMessage response = await client.SendAsync(request);
+
+ // Assert
+ Assert.NotNull(response);
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+
+ Assert.NotNull(response.Content);
+ string count = await response.Content.ReadAsStringAsync();
+
+ Assert.Equal("2", count);
+ }
+
+ private static void AssertJsonAddress(JObject address, string city, string street)
+ {
+ Assert.NotNull(address);
+ Assert.Equal(city, address["City"].ToObject());
+ Assert.Equal(street, address["Street"].ToObject());
+ }
+
+ private static void AssertJsonProduct(JObject product, int id, string name)
+ {
+ Assert.NotNull(product);
+ Assert.Equal(id, product["Id"].ToObject());
+ Assert.Equal(name, product["Name"].ToObject());
+ }
+ }
+
+ public class CustomersController
+ {
+ public IList Customers { get; set; }
+
+ public CustomersController()
+ {
+ Customers = Enumerable.Range(0, 10).Select(i => new Customer
+ {
+ Id = i,
+ Name = $"customer{i}",
+ Hobbies = new List { $"Running{i}", $"Swimming{i}"},
+ HomeAddress = new Address { City = $"City{i}", Street = $"Street{i}" },
+ OtherAddresses = new List()
+ {
+ new Address { City = $"CityA{i}", Street = $"StreetA{i}" },
+ new Address { City = $"CityB{i}", Street = $"StreetB{i}" }
+ },
+ FavoriteProduct = new Product { Id = i, Name = $"Product{i}" },
+ Products = new List
+ {
+ new Product { Id = 100 + i, Name = $"Product{100 + i }"},
+ new Product { Id = 101 + i, Name = $"Product{101 + i }"}
+ }
+ }).ToList();
+ }
+
+ [EnableQuery]
+ [EnableNestedPaths]
+ public IQueryable Get()
+ {
+ return Customers.AsQueryable();
+ }
+ }
+
+ public class TopCustomerController
+ {
+ [EnableNestedPaths]
+ public SingleResult Get()
+ {
+ var customer = new Customer
+ {
+ Id = 1,
+ Name = "customer1",
+ Hobbies = new List { "Running1", "Swimming1" },
+ HomeAddress = new Address { City = "City1", Street = "Street1" },
+ OtherAddresses = new List()
+ {
+ new Address { City = "CityA1", Street = "StreetA1" },
+ new Address { City = "CityB1", Street = "StreetB1" }
+ },
+ FavoriteProduct = new Product { Id = 1, Name = "Product1" },
+ Products = new List
+ {
+ new Product { Id = 101, Name = "Product101" },
+ new Product { Id = 102, Name = "Product102" }
+ }
+ };
+
+ return SingleResult.Create(new Customer[] { customer }.AsQueryable());
+ }
+ }
+
+ public class Customer
+ {
+ public int Id { get; set; }
+ public string Name { get; set; }
+ public List Hobbies { get; set; }
+ public Address HomeAddress { get; set; }
+ public List OtherAddresses { get; set; }
+ public Product FavoriteProduct { get; set; }
+ public List Products { get; set; }
+ }
+
+ public class Address
+ {
+ public string City { get; set; }
+ public string Street { get; set; }
+ }
+
+ public class Product
+ {
+ public int Id { get; set; }
+ public string Name { get; set; }
+ }
+}
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/Properties/AssemblyInfo.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/Properties/AssemblyInfo.cs
index bd6f826702..2e2249cfe5 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/Properties/AssemblyInfo.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/Properties/AssemblyInfo.cs
@@ -1,4 +1,11 @@
-using System.Reflection;
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
+
+using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/QueryValidationBeforeAction/QueryValidationBeforeActionController.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/QueryValidationBeforeAction/QueryValidationBeforeActionController.cs
index fcdbe825d5..bf9be9967a 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/QueryValidationBeforeAction/QueryValidationBeforeActionController.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/QueryValidationBeforeAction/QueryValidationBeforeActionController.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/QueryValidationBeforeAction/QueryValidationBeforeActionEdmModel.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/QueryValidationBeforeAction/QueryValidationBeforeActionEdmModel.cs
index bd0eeded4f..842a6291ae 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/QueryValidationBeforeAction/QueryValidationBeforeActionEdmModel.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/QueryValidationBeforeAction/QueryValidationBeforeActionEdmModel.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using Microsoft.OData.Edm;
using Microsoft.Test.E2E.AspNet.OData.Common.Execution;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/QueryValidationBeforeAction/QueryValidationBeforeActionODataModel.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/QueryValidationBeforeAction/QueryValidationBeforeActionODataModel.cs
index 44174aeb8a..8e74b8ccfd 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/QueryValidationBeforeAction/QueryValidationBeforeActionODataModel.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/QueryValidationBeforeAction/QueryValidationBeforeActionODataModel.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/QueryValidationBeforeAction/QueryValidationBeforeActionTests.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/QueryValidationBeforeAction/QueryValidationBeforeActionTests.cs
index e18dc03384..f65bd474b7 100644
--- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/QueryValidationBeforeAction/QueryValidationBeforeActionTests.cs
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNetCore3x/QueryValidationBeforeAction/QueryValidationBeforeActionTests.cs
@@ -1,5 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) .NET Foundation and Contributors. All rights reserved.
+// See License.txt in the project root for license information.
+//
+//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Linq;
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/BulkOperation/BulkInsertController.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/BulkOperation/BulkInsertController.cs
new file mode 100644
index 0000000000..08acfa04d5
--- /dev/null
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/BulkOperation/BulkInsertController.cs
@@ -0,0 +1,661 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Reflection;
+using Microsoft.AspNet.OData;
+using Microsoft.AspNet.OData.Extensions;
+using Microsoft.AspNet.OData.Routing;
+using Microsoft.OData.Edm;
+using Microsoft.Test.E2E.AspNet.OData.BulkOperation;
+using Microsoft.Test.E2E.AspNet.OData.Common.Controllers;
+using Xunit;
+
+namespace Microsoft.Test.E2E.AspNet.OData.BulkInsert
+{
+ public class EmployeesController : TestODataController
+ {
+ public EmployeesController()
+ {
+ if (null == Employees)
+ {
+ InitEmployees();
+ }
+ }
+
+ ///
+ /// static so that the data is shared among requests.
+ ///
+ public static IList Employees = null;
+
+ public static IList EmployeesTypeless = null;
+
+ private List Friends = null;
+
+
+ private void InitEmployees()
+ {
+ Friends = new List { new Friend { Id = 1, Name = "Test0", Age =33 }, new Friend { Id = 2, Name = "Test1", Orders = new List() { new Order { Id = 1, Price = 2 } } }, new Friend { Id = 3, Name = "Test3" }, new Friend { Id = 4, Name = "Test4" } };
+
+ Employees = new List
+ {
+ new Employee()
+ {
+ ID=1,
+ Name="Name1",
+ SkillSet=new List{Skill.CSharp,Skill.Sql},
+ Gender=Gender.Female,
+ AccessLevel=AccessLevel.Execute,
+ NewFriends = new List(){new NewFriend {Id =1, Name ="NewFriendTest1", Age=33, NewOrders= new List() { new NewOrder {Id=1, Price =101 } } } },
+ Friends = this.Friends.Where(x=>x.Id ==1 || x.Id==2).ToList()
+ },
+ new Employee()
+ {
+ ID=2,Name="Name2",
+ SkillSet=new List(),
+ Gender=Gender.Female,
+ AccessLevel=AccessLevel.Read,
+ NewFriends = new List(){ new MyNewFriend { Id = 2, MyNewOrders = new List() { new MyNewOrder { Id = 2, Price = 444 , Quantity=2 } } } },
+ Friends = this.Friends.Where(x=>x.Id ==3 || x.Id==4).ToList()
+ },
+ new Employee(){
+ ID=3,Name="Name3",
+ SkillSet=new List{Skill.Web,Skill.Sql},
+ Gender=Gender.Female,
+ AccessLevel=AccessLevel.Read|AccessLevel.Write
+
+ },
+ };
+ }
+
+ private void InitTypeLessEmployees(IEdmEntityType entityType)
+ {
+ EmployeesTypeless = new List();
+ var emp1 = new EdmEntityObject(entityType);
+ emp1.TrySetPropertyValue("ID", 1);
+ emp1.TrySetPropertyValue("Name", "Test1");
+
+ var friendType = entityType.DeclaredNavigationProperties().First().Type.Definition.AsElementType() as IEdmEntityType;
+
+ var friends = new List();
+ var friend1 = new EdmEntityObject(friendType);
+ friend1.TrySetPropertyValue("Id", 1);
+ friend1.TrySetPropertyValue("Age", 33);
+ friend1.TrySetPropertyValue("Name", "Test1");
+
+ var friend2 = new EdmEntityObject(friendType);
+ friend2.TrySetPropertyValue("Id", 2);
+ friend2.TrySetPropertyValue("Name", "Test2");
+
+ friends.Add(friend1);
+ friends.Add(friend2);
+
+ emp1.TrySetPropertyValue("UnTypedFriends", friends);
+
+ var emp2 = new EdmEntityObject(entityType);
+ emp2.TrySetPropertyValue("ID", 2);
+ emp2.TrySetPropertyValue("Name", "Test2");
+
+ var friends2 = new List();
+ var friend3 = new EdmEntityObject(friendType);
+ friend3.TrySetPropertyValue("Id", 3);
+ friend3.TrySetPropertyValue("Name", "Test3");
+
+ var friend4 = new EdmEntityObject(friendType);
+ friend4.TrySetPropertyValue("Id", 4);
+ friend4.TrySetPropertyValue("Name", "Test4");
+
+ friends2.Add(friend3);
+ friends2.Add(friend4);
+
+ emp2.TrySetPropertyValue("UnTypedFriends", friends2);
+
+ var emp3 = new EdmEntityObject(entityType);
+ emp3.TrySetPropertyValue("ID", 3);
+ emp3.TrySetPropertyValue("Name", "Test3");
+
+ var friends35 = new List();
+ var friend5 = new EdmEntityObject(friendType);
+ friend5.TrySetPropertyValue("Id", 5);
+ friend5.TrySetPropertyValue("Name", "Test5");
+
+ friends35.Add(friend5);
+
+ emp3.TrySetPropertyValue("UnTypedFriends", friends35);
+
+ EmployeesTypeless.Add(emp1);
+ EmployeesTypeless.Add(emp2);
+ EmployeesTypeless.Add(emp3);
+ }
+
+ public DeltaSet PatchWithUsersMethod(DeltaSet friendColl, Employee employee)
+ {
+ var changedObjColl = friendColl.Patch(new APIHandlerFactory(employee));
+
+ return changedObjColl;
+ }
+ public EdmChangedObjectCollection PatchWithUsersMethodTypeLess(int key, EdmChangedObjectCollection friendColl)
+ {
+
+ var entity = Request.GetModel().FindDeclaredType("Microsoft.Test.E2E.AspNet.OData.BulkInsert.UnTypedEmployee") as IEdmEntityType;
+ InitTypeLessEmployees(entity);
+
+ var entity1 = Request.GetModel().FindDeclaredType("Microsoft.Test.E2E.AspNet.OData.BulkInsert.UnTypedFriend") as IEdmEntityType;
+
+ var changedObjColl = friendColl.Patch(new TypelessAPIHandlerFactory(entity, EmployeesTypeless[key - 1]));
+
+ return changedObjColl;
+ }
+
+ public EdmChangedObjectCollection EmployeePatchMethodTypeLess(EdmChangedObjectCollection empColl)
+ {
+ var entity = Request.GetModel().FindDeclaredType("Microsoft.Test.E2E.AspNet.OData.BulkInsert.UnTypedEmployee") as IEdmEntityType;
+ InitTypeLessEmployees(entity);
+
+ var changedObjColl = empColl.Patch(new TypelessAPIHandlerFactory(entity));
+ ValidateSuccessfulTypeless();
+
+ return changedObjColl;
+ }
+
+ private void ValidateSuccessfulTypeless()
+ {
+ object obj;
+ Assert.True(EmployeesTypeless.First().TryGetPropertyValue("UnTypedFriends", out obj));
+
+ var friends = obj as ICollection;
+ Assert.NotNull(friends);
+
+ object obj1;
+
+ friends.First().TryGetPropertyValue("Name", out obj1);
+
+ object name;
+ if (EmployeesTypeless.First().TryGetPropertyValue("Name", out name) && name.ToString() == "Employeeabcd")
+ {
+ Assert.Equal("abcd", obj1.ToString());
+
+ object age;
+ friends.First().TryGetPropertyValue("Age", out age);
+
+ Assert.Equal(33, (int)age);
+ }
+ else
+ {
+ Assert.Equal("Friend1", obj1.ToString());
+ }
+
+ }
+
+ [EnableQuery(PageSize = 10, MaxExpansionDepth = 5)]
+ public ITestActionResult Get()
+ {
+ return Ok(Employees.AsQueryable());
+ }
+
+ public ITestActionResult Get(int key)
+ {
+ var emp = Employees.SingleOrDefault(e => e.ID == key);
+ return Ok(emp);
+ }
+
+ [ODataRoute("Employees({key})/Friends")]
+ public ITestActionResult GetFriends(int key)
+ {
+ var emp = Employees.SingleOrDefault(e => e.ID == key);
+ return Ok(emp.Friends);
+ }
+
+ [ODataRoute("Employees({key})/UnTypedFriends")]
+ public ITestActionResult GetUnTypedFriends(int key)
+ {
+ var entity = Request.GetModel().FindDeclaredType("Microsoft.Test.E2E.AspNet.OData.BulkInsert.UnTypedEmployee") as IEdmEntityType;
+ InitTypeLessEmployees(entity);
+
+ foreach (var emp in EmployeesTypeless)
+ {
+ object obj;
+ emp.TryGetPropertyValue("ID", out obj);
+
+ if (Equals(key, obj))
+ {
+ object friends;
+ emp.TryGetPropertyValue("UntypedFriends", out friends);
+ return Ok(friends);
+ }
+ }
+ return Ok();
+ }
+
+
+ [ODataRoute("Employees")]
+ [HttpPatch]
+ public ITestActionResult PatchEmployees([FromBody] DeltaSet coll)
+ {
+ InitEmployees();
+
+ Assert.NotNull(coll);
+
+ var returncoll = coll.Patch(new APIHandlerFactory());
+
+ return Ok(returncoll);
+ }
+
+
+ [ODataRoute("Employees({key})/Friends")]
+ [HttpPatch]
+ public ITestActionResult PatchFriends(int key, [FromBody] DeltaSet friendColl)
+ {
+ InitEmployees();
+
+ Employee originalEmployee = Employees.SingleOrDefault(c => c.ID == key);
+ Assert.NotNull(originalEmployee);
+
+ var changedObjColl = friendColl.Patch(originalEmployee.Friends);
+
+ return Ok(changedObjColl);
+ }
+
+
+ [ODataRoute("Employees({key})/NewFriends")]
+ [HttpPatch]
+ public ITestActionResult PatchNewFriends(int key, [FromBody] DeltaSet friendColl)
+ {
+ InitEmployees();
+
+ if (key == 1)
+ {
+ var deltaSet = PatchWithUsersMethod(friendColl, Employees.First(x => x.ID == key));
+
+ return Ok(deltaSet);
+ }
+ {
+ Employee originalEmployee = Employees.SingleOrDefault(c => c.ID == key);
+ Assert.NotNull(originalEmployee);
+
+ var friendCollection = new FriendColl() { new NewFriend { Id = 2, Age = 15 } };
+
+ var changedObjColl = friendColl.Patch(friendCollection);
+
+ return Ok(changedObjColl);
+ }
+
+ }
+
+ [ODataRoute("Employees({key})/UnTypedFriends")]
+ [HttpPatch]
+ public ITestActionResult PatchUnTypedFriends(int key, [FromBody] EdmChangedObjectCollection friendColl)
+ {
+ if (key == 1)
+ {
+ var changedObjColl = PatchWithUsersMethodTypeLess(key, friendColl);
+
+ var emp = EmployeesTypeless[key - 1];
+ object obj;
+ emp.TryGetPropertyValue("UnTypedFriends", out obj);
+ var lst = obj as List;
+
+ if (lst != null && lst.Count > 1)
+ {
+ object obj1;
+ if (lst[1].TryGetPropertyValue("Name", out obj1) && Equals("Friend007", obj1))
+ {
+ lst[1].TryGetPropertyValue("Address", out obj1);
+ Assert.NotNull(obj1);
+ object obj2;
+ (obj1 as EdmStructuredObject).TryGetPropertyValue("Street", out obj2);
+
+ Assert.Equal("Abc 123", obj2);
+
+ }
+ }
+
+ return Ok(changedObjColl);
+ }
+ else if (key == 2)
+ {
+ var entitytype = Request.GetModel().FindDeclaredType("Microsoft.Test.E2E.AspNet.OData.BulkInsert.UnTypedEmployee") as IEdmEntityType;
+ var entity = new EdmEntityObject(friendColl[0].GetEdmType().AsEntity());
+ entity.TrySetPropertyValue("Id", 2);
+
+ var friendCollection = new FriendColl() { entity };
+
+ var changedObjColl = PatchWithUsersMethodTypeLess(key, friendColl);
+
+ object obj;
+ Assert.Single(changedObjColl);
+
+ changedObjColl.First().TryGetPropertyValue("Age", out obj);
+ Assert.Equal(35, obj);
+
+ return Ok(changedObjColl);
+ }
+ else
+ {
+ var changedObjColl = PatchWithUsersMethodTypeLess(key, friendColl);
+
+ return Ok(changedObjColl);
+ }
+ }
+
+
+ [ODataRoute("UnTypedEmployees")]
+ [HttpPatch]
+ public ITestActionResult PatchUnTypedEmployees([FromBody] EdmChangedObjectCollection empColl)
+ {
+
+ var changedObjColl = EmployeePatchMethodTypeLess(empColl);
+
+ return Ok(changedObjColl);
+
+ }
+
+
+
+ [ODataRoute("Employees({key})")]
+ public ITestActionResult Patch(int key, [FromBody] Delta delta)
+ {
+ InitEmployees();
+
+ delta.TrySetPropertyValue("ID", key); // It is the key property, and should not be updated.
+
+ Employee employee = Employees.FirstOrDefault(e => e.ID == key);
+
+ if (employee == null)
+ {
+ employee = new Employee();
+ delta.Patch(employee, new APIHandlerFactory());
+ return Created(employee);
+ }
+
+ try
+ {
+ delta.Patch(employee, new APIHandlerFactory());
+
+ if (employee.Name == "Bind1")
+ {
+ Assert.NotNull(employee.Friends.Single(x => x.Id == 3));
+ }
+ }
+ catch (ArgumentException ae)
+ {
+ return BadRequest(ae.Message);
+ }
+
+ return Ok(employee);
+ }
+
+
+ }
+
+ public class CompanyController : TestODataController
+ {
+ public static IList Companies = null;
+ public static IList OverdueOrders = null;
+ public static IList MyOverdueOrders = null;
+
+ public CompanyController()
+ {
+ if (null == Companies)
+ {
+ InitCompanies();
+ }
+ }
+
+ private void InitCompanies()
+ {
+ OverdueOrders = new List() { new NewOrder { Id = 1, Price = 10, Quantity =1 }, new NewOrder { Id = 2, Price = 20, Quantity = 2 }, new NewOrder { Id = 3, Price = 30 }, new NewOrder { Id = 4, Price = 40 } };
+ MyOverdueOrders = new List() { new MyNewOrder { Id = 1, Price = 10, Quantity = 1 }, new MyNewOrder { Id = 2, Price = 20, Quantity = 2 }, new MyNewOrder { Id = 3, Price = 30 }, new MyNewOrder { Id = 4, Price = 40 } };
+
+ Companies = new List() { new Company { Id = 1, Name = "Company1", OverdueOrders = OverdueOrders.Where(x => x.Id == 2).ToList(), MyOverdueOrders = MyOverdueOrders.Where(x => x.Id == 2).ToList() } ,
+ new Company { Id = 2, Name = "Company2", OverdueOrders = OverdueOrders.Where(x => x.Id == 3 || x.Id == 4).ToList() } };
+ }
+
+
+ [ODataRoute("Companies")]
+ [HttpPatch]
+ public ITestActionResult PatchCompanies([FromBody] DeltaSet coll)
+ {
+ var empCntrl = new EmployeesController();
+ InitCompanies();
+
+ Assert.NotNull(coll);
+
+ var returncoll = coll.Patch( new APIHandlerFactory());
+
+ var comp = coll.First() as Delta;
+ object val;
+ if(comp.TryGetPropertyValue("Name", out val))
+ {
+ if(val.ToString() == "Company02")
+ {
+ ValidateOverdueOrders2(1, 2, 9);
+ }
+ else
+ {
+ ValidateOverdueOrders1(1, 1, 9);
+ }
+ }
+
+
+ return Ok(returncoll);
+ }
+
+ [ODataRoute("Companies")]
+ [HttpPost]
+ public ITestActionResult Post([FromBody] Company company)
+ {
+
+ InitCompanies();
+ InitEmployees();
+
+ if(company.Id == 4)
+ {
+ AddNewOrder(company);
+ }
+
+ //MapOdataId(company);
+ CheckAndApplyODataId(company );
+
+ Companies.Add(company);
+
+ if (company.Id == 4)
+ {
+ ValidateOverdueOrders1(4, 4, 0, 30);
+ }
+ else
+ {
+ ValidateOverdueOrders1(3, 1);
+ }
+
+
+ return Ok(company);
+ }
+
+ private static void AddNewOrder(Company company)
+ {
+ var newOrder = new NewOrder { Id = 4, Price = company.OverdueOrders[1].Price, Quantity = company.OverdueOrders[1].Quantity };
+ OverdueOrders.Add(newOrder);
+ company.OverdueOrders[1] = newOrder;
+ }
+
+
+ private void MapOdataId(Company company)
+ {
+ //More generic.
+ for(int i =0; i< company.OverdueOrders.Count;i++)
+ {
+ var order = company.OverdueOrders[i];
+ if(order.Container != null)
+ {
+ var pathItems = order.Container.ODataIdNavigationPath.GetNavigationPathItems();
+
+ int cnt = 0;
+ if(pathItems[cnt].Name== "Employees")
+ {
+ var emp = GetEmployee(pathItems[cnt].KeyProperties);
+
+ if(emp != null)
+ {
+ if(pathItems[++cnt].Name == "NewFriends")
+ {
+ var frnd = GetNewFriendFromEmployee(emp, pathItems[cnt].KeyProperties);
+
+ if(frnd!= null)
+ {
+ if (pathItems[++cnt].Name == "NewOrders")
+ {
+ //{ ID= 1, OdataIdContainer {....}} - add comments.
+ company.OverdueOrders[i] = GetNewOrderFromNewFriend(frnd, pathItems[cnt].KeyProperties);
+ }
+ }
+ }
+ }
+ }
+
+ }
+ }
+ }
+
+
+
+ private void CheckAndApplyODataId(object obj)
+ {
+ Type type = obj.GetType();
+
+ PropertyInfo property = type.GetProperties().FirstOrDefault(s => s.PropertyType == typeof(ODataIdContainer));
+
+ if(property != null && property.GetValue(obj) is ODataIdContainer container && container != null)
+ {
+ var res = ApplyODataId(container);
+
+ foreach(var prop in type.GetProperties())
+ {
+ var resVal = prop.GetValue(res);
+
+
+ if(resVal != null)
+ {
+ prop.SetValue(obj, resVal);
+ }
+ }
+ }
+ else
+ {
+ foreach (var prop in type.GetProperties().Where(p=> p.PropertyType.IsGenericType && typeof(IEnumerable).IsAssignableFrom(p.PropertyType)))
+ {
+ var lst = (IEnumerable)prop.GetValue(obj) ;
+ if(lst == null)
+ {
+ continue;
+ }
+
+ foreach (var val in lst)
+ {
+ if (val.GetType().IsPrimitive)
+ {
+ break;
+ }
+
+ CheckAndApplyODataId(val);
+
+ }
+ }
+ }
+
+ }
+
+ private object ApplyODataId(ODataIdContainer container)
+ {
+ var pathItems = container.ODataIdNavigationPath.GetNavigationPathItems();
+ if(pathItems != null)
+ {
+ int cnt = 0;
+ object value = null;
+
+ while(cnt< pathItems.Length)
+ {
+ value = GetObject(pathItems[cnt].Name, value, pathItems[cnt].KeyProperties);
+ cnt++;
+ }
+
+ return value;
+ }
+
+ return null;
+ }
+
+ private object GetObject(string name, object parent, Dictionary keyValues)
+ {
+ switch (name)
+ {
+ case "Employees":
+ return EmployeesController.Employees.FirstOrDefault(x => x.ID == (int)keyValues["ID"]);
+ case "NewFriends":
+ Employee emp = parent as Employee;
+
+ return emp == null? null: emp.NewFriends.FirstOrDefault(x => x.Id == (int)keyValues["Id"]);
+ case "NewOrders":
+ NewFriend frnd = parent as NewFriend;
+
+ return frnd == null ? null : frnd.NewOrders.FirstOrDefault(x => x.Id == (int)keyValues["Id"]);
+ default:
+ return null;
+ }
+ }
+
+ private Employee GetEmployee(Dictionary keyValues)
+ {
+ var emp = EmployeesController.Employees.FirstOrDefault(x => x.ID == (int)keyValues["ID"]);
+
+ return emp;
+ }
+
+ private NewFriend GetNewFriendFromEmployee(Employee emp, Dictionary keyValues)
+ {
+ var frnd = emp.NewFriends.FirstOrDefault(x => x.Id == (int)keyValues["Id"]);
+
+ return frnd;
+ }
+
+ private NewOrder GetNewOrderFromNewFriend(NewFriend frnd, Dictionary keyValues)
+ {
+ var order = frnd.NewOrders.FirstOrDefault(x => x.Id == (int)keyValues["Id"]);
+
+ return order;
+ }
+
+ private void InitEmployees()
+ {
+ var cntrl = new EmployeesController();
+ }
+
+ private void ValidateOverdueOrders1(int companyId, int orderId, int quantity = 0, int price=101)
+ {
+ var comp = Companies.FirstOrDefault(x => x.Id == companyId);
+ Assert.NotNull(comp);
+
+ NewOrder order = comp.OverdueOrders.FirstOrDefault(x => x.Id == orderId);
+ Assert.NotNull(order);
+ Assert.Equal(orderId, order.Id);
+ Assert.Equal(price, order.Price);
+ Assert.Equal(quantity, order.Quantity);
+ }
+
+ private void ValidateOverdueOrders2(int companyId, int orderId, int quantity = 0)
+ {
+ var comp = Companies.FirstOrDefault(x => x.Id == companyId);
+ Assert.NotNull(comp);
+
+ MyNewOrder order = comp.MyOverdueOrders.FirstOrDefault(x => x.Id == orderId);
+ Assert.NotNull(order);
+ Assert.Equal(orderId, order.Id);
+ Assert.Equal(444, order.Price);
+ Assert.Equal(quantity, order.Quantity);
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/BulkOperation/BulkInsertDataModel.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/BulkOperation/BulkInsertDataModel.cs
new file mode 100644
index 0000000000..76cbcb9301
--- /dev/null
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/BulkOperation/BulkInsertDataModel.cs
@@ -0,0 +1,226 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using Microsoft.AspNet.OData;
+using Microsoft.AspNet.OData.Builder;
+
+namespace Microsoft.Test.E2E.AspNet.OData.BulkInsert
+{
+ public class Employee
+ {
+ [Key]
+ public int ID { get; set; }
+ public String Name { get; set; }
+ public List SkillSet { get; set; }
+ public Gender Gender { get; set; }
+ public AccessLevel AccessLevel { get; set; }
+
+ [AutoExpand]
+ public List Friends { get; set; }
+
+ public List NewFriends { get; set; }
+
+ public List UnTypedFriends { get; set; }
+
+ public IODataInstanceAnnotationContainer InstanceAnnotations { get; set; }
+ }
+
+ [Flags]
+ public enum AccessLevel
+ {
+ Read = 1,
+ Write = 2,
+ Execute = 4
+ }
+
+ public enum Gender
+ {
+ Male = 1,
+ Female = 2
+ }
+
+ public enum Skill
+ {
+ CSharp,
+ Sql,
+ Web,
+ }
+
+ public enum Sport
+ {
+ Pingpong,
+ Basketball
+ }
+
+ public class Friend
+ {
+ [Key]
+ public int Id { get; set; }
+ [Required]
+ public string Name { get; set; }
+ [Range(10, 20)]
+ public int Age { get; set; }
+
+ public List Orders { get; set; }
+
+ }
+
+
+ public class Order
+ {
+ [Key]
+ public int Id { get; set; }
+
+ public int Price { get; set; }
+ }
+
+ public class NewFriend
+ {
+ [Key]
+ public int Id { get; set; }
+
+ public string Name { get; set; }
+
+ public int Age { get; set; }
+ public IODataInstanceAnnotationContainer InstanceAnnotations { get; set; }
+
+ [Contained]
+ public List NewOrders { get; set; }
+
+ }
+
+ public class MyNewFriend: NewFriend
+ {
+ public string MyName { get; set; }
+
+ [Contained]
+ public List MyNewOrders { get; set; }
+ }
+
+ public class MyNewOrder
+ {
+ [Key]
+ public int Id { get; set; }
+
+ public int Price { get; set; }
+
+ public int Quantity { get; set; }
+
+ public ODataIdContainer Container { get; set; }
+ }
+
+ public class NewOrder
+ {
+ [Key]
+ public int Id { get; set; }
+
+ public int Price { get; set; }
+
+ public int Quantity { get; set; }
+
+ public ODataIdContainer Container {get;set;}
+ }
+
+
+ public class Company
+ {
+ [Key]
+ public int Id { get; set; }
+
+ public string Name { get; set; }
+
+ public List OverdueOrders { get; set; }
+
+ public List MyOverdueOrders { get; set; }
+ }
+
+ public class UnTypedEmployee
+ {
+ [Key]
+ public int ID { get; set; }
+ public String Name { get; set; }
+
+ public List UnTypedFriends { get; set; }
+ }
+
+ public class UnTypedFriend
+ {
+ [Key]
+ public int Id { get; set; }
+
+ public string Name { get; set; }
+
+ public int Age { get; set; }
+
+ public UnTypedAddress Address { get; set; }
+
+ public IODataInstanceAnnotationContainer InstanceAnnotations { get; set; }
+ }
+
+ public class UnTypedAddress
+ {
+ [Key]
+ public int Id { get; set; }
+
+ public string Street { get; set; }
+ }
+
+ public class FriendColl : ICollection
+ {
+ public FriendColl() { _items = new List(); }
+
+ private IList _items;
+
+ public int Count => _items.Count;
+
+ public bool IsReadOnly => _items.IsReadOnly;
+
+ public void Add(T item)
+ {
+ var _item = item as NewFriend;
+ if (_item != null && _item.Age < 10)
+ {
+ throw new NotImplementedException();
+ }
+
+ _items.Add(item);
+ }
+
+ public void Clear()
+ {
+ _items.Clear();
+ }
+
+ public bool Contains(T item)
+ {
+ return _items.Contains(item);
+ }
+
+ public void CopyTo(T[] array, int arrayIndex)
+ {
+ _items.CopyTo(array, arrayIndex);
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ return _items.GetEnumerator();
+ }
+
+ public bool Remove(T item)
+ {
+ throw new NotImplementedException();
+
+ //return _items.Remove(item);
+ }
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return ((IEnumerable)_items).GetEnumerator();
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/BulkOperation/BulkInsertEdmModel.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/BulkOperation/BulkInsertEdmModel.cs
new file mode 100644
index 0000000000..88fa414c05
--- /dev/null
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/BulkOperation/BulkInsertEdmModel.cs
@@ -0,0 +1,107 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+
+using Microsoft.AspNet.OData.Builder;
+using Microsoft.OData.Edm;
+using Microsoft.Test.E2E.AspNet.OData.Common.Execution;
+
+namespace Microsoft.Test.E2E.AspNet.OData.BulkInsert
+{
+ internal class BulkInsertEdmModel
+ {
+ public static IEdmModel GetExplicitModel(WebRouteConfiguration configuration)
+ {
+ ODataModelBuilder builder = new ODataModelBuilder();
+ var employee = builder.EntityType();
+ employee.HasKey(c => c.ID);
+ employee.Property(c => c.Name);
+ employee.CollectionProperty(c => c.SkillSet);
+ employee.EnumProperty(c => c.Gender);
+ employee.EnumProperty(c => c.AccessLevel);
+
+ employee.CollectionProperty(c => c.Friends);
+ employee.CollectionProperty(c => c.NewFriends);
+ employee.CollectionProperty(c => c.UnTypedFriends);
+
+
+ var skill = builder.EnumType();
+ skill.Member(Skill.CSharp);
+ skill.Member(Skill.Sql);
+ skill.Member(Skill.Web);
+
+ var gender = builder.EnumType();
+ gender.Member(Gender.Female);
+ gender.Member(Gender.Male);
+
+ var accessLevel = builder.EnumType();
+ accessLevel.Member(AccessLevel.Execute);
+ accessLevel.Member(AccessLevel.Read);
+ accessLevel.Member(AccessLevel.Write);
+
+ var sport = builder.EnumType();
+ sport.Member(Sport.Basketball);
+ sport.Member(Sport.Pingpong);
+
+ AddBoundActionsAndFunctions(employee);
+ AddUnboundActionsAndFunctions(builder);
+
+ EntitySetConfiguration employees = builder.EntitySet("Employees");
+ builder.Namespace = typeof(Employee).Namespace;
+ return builder.GetEdmModel();
+ }
+
+ public static IEdmModel GetConventionModel(WebRouteConfiguration configuration)
+ {
+ ODataConventionModelBuilder builder = configuration.CreateConventionModelBuilder();
+ EntitySetConfiguration employees = builder.EntitySet("Employees");
+ EntityTypeConfiguration employee = employees.EntityType;
+
+ EntitySetConfiguration friends = builder.EntitySet("Friends");
+ EntitySetConfiguration orders = builder.EntitySet("Orders");
+ EntitySetConfiguration fnewriends = builder.EntitySet("NewFriends");
+ EntitySetConfiguration funtypenewriends = builder.EntitySet("UnTypedFriends");
+ EntitySetConfiguration addresses = builder.EntitySet("Address");
+
+ EntitySetConfiguration unemployees = builder.EntitySet("UnTypedEmployees");
+ EntityTypeConfiguration unemployee = unemployees.EntityType;
+
+ EntitySetConfiguration companies = builder.EntitySet("Companies");
+ EntitySetConfiguration overdueorders = builder.EntitySet("OverdueOrders");
+ EntitySetConfiguration myoverdueorders = builder.EntitySet("MyOverdueOrders");
+ EntitySetConfiguration myNewOrders = builder.EntitySet("MyNewOrders");
+
+ // maybe following lines are not required once bug #1587 is fixed.
+ // 1587: It's better to support automatically adding actions and functions in ODataConventionModelBuilder.
+ AddBoundActionsAndFunctions(employee);
+ AddUnboundActionsAndFunctions(builder);
+
+ builder.Namespace = typeof(Employee).Namespace;
+
+ var edmModel = builder.GetEdmModel();
+ return edmModel;
+ }
+
+ private static void AddBoundActionsAndFunctions(EntityTypeConfiguration employee)
+ {
+ var actionConfiguration = employee.Action("AddSkill");
+ actionConfiguration.Parameter("skill");
+ actionConfiguration.ReturnsCollection();
+
+ var functionConfiguration = employee.Function("GetAccessLevel");
+ functionConfiguration.Returns();
+ }
+
+ private static void AddUnboundActionsAndFunctions(ODataModelBuilder odataModelBuilder)
+ {
+ var actionConfiguration = odataModelBuilder.Action("SetAccessLevel");
+ actionConfiguration.Parameter("ID");
+ actionConfiguration.Parameter("accessLevel");
+ actionConfiguration.Returns();
+
+ var functionConfiguration = odataModelBuilder.Function("HasAccessLevel");
+ functionConfiguration.Parameter("ID");
+ functionConfiguration.Parameter("AccessLevel");
+ functionConfiguration.Returns();
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/BulkOperation/BulkInsertTest.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/BulkOperation/BulkInsertTest.cs
new file mode 100644
index 0000000000..434f060a56
--- /dev/null
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/BulkOperation/BulkInsertTest.cs
@@ -0,0 +1,959 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+
+using System;
+using System.Linq;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text;
+using System.Threading.Tasks;
+using Microsoft.AspNet.OData;
+using Microsoft.AspNet.OData.Extensions;
+using Microsoft.AspNet.OData.Routing;
+using Microsoft.AspNet.OData.Routing.Conventions;
+using Microsoft.OData;
+using Microsoft.OData.Edm;
+using Microsoft.Test.E2E.AspNet.OData.Common.Execution;
+using Microsoft.Test.E2E.AspNet.OData.Common.Extensions;
+using Microsoft.Test.E2E.AspNet.OData.ModelBuilder;
+using Newtonsoft.Json.Linq;
+using Xunit;
+
+namespace Microsoft.Test.E2E.AspNet.OData.BulkInsert
+{
+ public class BulkInsertTest : WebHostTestBase
+ {
+ public BulkInsertTest(WebHostTestFixture fixture)
+ :base(fixture)
+ {
+ }
+
+ protected override void UpdateConfiguration(WebRouteConfiguration configuration)
+ {
+ var controllers = new[] { typeof(EmployeesController), typeof(CompanyController), typeof(MetadataController) };
+ configuration.AddControllers(controllers);
+
+ configuration.Routes.Clear();
+ configuration.Count().Filter().OrderBy().Expand().MaxTop(null).Select();
+ configuration.MapODataServiceRoute("convention", "convention", BulkInsertEdmModel.GetConventionModel(configuration));
+ configuration.MapODataServiceRoute("explicit", "explicit", BulkInsertEdmModel.GetExplicitModel(configuration), new DefaultODataPathHandler(), ODataRoutingConventions.CreateDefault());
+ configuration.EnsureInitialized();
+ }
+
+
+ #region Update
+
+ [Fact]
+ public async Task PatchEmployee_WithUpdates()
+ {
+ //Arrange
+
+ string requestUri = this.BaseAddress + "/convention/Employees(1)";
+
+ var content = @"{
+ 'Name':'Sql' ,
+ 'Friends@odata.delta':[{'Id':1,'Name':'Test2'},{'Id':2,'Name':'Test3'}]
+ }";
+
+
+ var requestForPost = new HttpRequestMessage(new HttpMethod("PATCH"), requestUri);
+
+ StringContent stringContent = new StringContent(content: content, encoding: Encoding.UTF8, mediaType: "application/json");
+ requestForPost.Content = stringContent;
+
+ //Act
+ using (HttpResponseMessage response = await this.Client.SendAsync(requestForPost))
+ {
+ var json = response.Content.ReadAsStringAsync().Result;
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ }
+
+ //Assert
+ requestUri = this.BaseAddress + "/convention/Employees(1)/Friends";
+ using (HttpResponseMessage response = await this.Client.GetAsync(requestUri))
+ {
+ response.EnsureSuccessStatusCode();
+
+ var json = await response.Content.ReadAsObject();
+ var result = json.GetValue("value") as JArray;
+
+ Assert.Equal(2, result.Count);
+ Assert.Contains("Test2", result.ToString());
+ }
+
+ }
+
+ [Fact]
+ public async Task PatchEmployee_WithUpdates_WithEmployees()
+ {
+ //Arrange
+
+ string requestUri = this.BaseAddress + "/convention/Employees(1)";
+
+ var content = @"{
+ 'Name':'Sql' ,
+ 'Friends':[{'Id':345,'Name':'Test2'},{'Id':400,'Name':'Test3'},{'Id':900,'Name':'Test93'}]
+ }";
+
+ var requestForPost = new HttpRequestMessage(new HttpMethod("PATCH"), requestUri);
+
+ StringContent stringContent = new StringContent(content: content, encoding: Encoding.UTF8, mediaType: "application/json");
+ requestForPost.Content = stringContent;
+
+ using (HttpResponseMessage response = await this.Client.SendAsync(requestForPost))
+ {
+ var json = response.Content.ReadAsStringAsync().Result;
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ }
+
+ //Assert
+ requestUri = this.BaseAddress + "/convention/Employees(1)/Friends";
+ using (HttpResponseMessage response = await this.Client.GetAsync(requestUri))
+ {
+ response.EnsureSuccessStatusCode();
+
+ var json = await response.Content.ReadAsObject();
+ var result = json.GetValue("value") as JArray;
+
+ Assert.Equal(3, result.Count);
+ Assert.Contains("345", result.ToString());
+ Assert.Contains("400", result.ToString());
+ Assert.Contains("900", result.ToString());
+ }
+
+ }
+
+
+ [Fact]
+ public async Task PatchEmployee_WithUpdates_Friends()
+ {
+ //Arrange
+
+ string requestUri = this.BaseAddress + "/convention/Employees(1)/Friends";
+
+ var content = @"{'@odata.type': '#Microsoft.Test.E2E.AspNet.OData.BulkInsert.Friend',
+ '@odata.context':'" + this.BaseAddress + @"/convention/$metadata#Employees(1)/Friends/$delta',
+ 'value':[{ 'Id':1,'Name':'Friend1'}, { 'Id':2,'Name':'Friend2'}]
+ }";
+
+ var requestForPost = new HttpRequestMessage(new HttpMethod("PATCH"), requestUri);
+
+ StringContent stringContent = new StringContent(content: content, encoding: Encoding.UTF8, mediaType: "application/json");
+ requestForPost.Content = stringContent;
+ Client.DefaultRequestHeaders.Add("Prefer", @"odata.include-annotations=""*""");
+
+ using (HttpResponseMessage response = await this.Client.SendAsync(requestForPost))
+ {
+ var json = response.Content.ReadAsStringAsync().Result;
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ }
+
+ //Assert
+ requestUri = this.BaseAddress + "/convention/Employees(1)/Friends";
+ using (HttpResponseMessage response = await this.Client.GetAsync(requestUri))
+ {
+ response.EnsureSuccessStatusCode();
+
+ var json = await response.Content.ReadAsObject();
+ var result = json.GetValue("value") as JArray;
+
+ Assert.Equal(2, result.Count);
+ Assert.Contains("Friend1", result.ToString());
+ Assert.Contains("Friend2", result.ToString());
+ }
+ }
+
+ [Fact]
+ public async Task PatchEmployee_WithDeletes_Friends()
+ {
+ //Arrange
+
+ string requestUri = this.BaseAddress + "/convention/Employees(1)/Friends";
+
+ var content = @"{'@odata.context':'" + this.BaseAddress + @"/convention/$metadata#Employees(1)/Friends/$delta',
+ 'value':[{ '@odata.removed' : {'reason':'changed'}, 'Id':1},{ 'Id':2,'Name':'Friend2'}]
+ }";
+
+ var requestForPost = new HttpRequestMessage(new HttpMethod("PATCH"), requestUri);
+
+ StringContent stringContent = new StringContent(content: content, encoding: Encoding.UTF8, mediaType: "application/json");
+ requestForPost.Content = stringContent;
+
+ using (HttpResponseMessage response = await this.Client.SendAsync(requestForPost))
+ {
+ var json = response.Content.ReadAsStringAsync().Result;
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ }
+
+ //Assert
+ requestUri = this.BaseAddress + "/convention/Employees(1)/Friends";
+ using (HttpResponseMessage response = await this.Client.GetAsync(requestUri))
+ {
+ response.EnsureSuccessStatusCode();
+
+ var json = await response.Content.ReadAsObject();
+ var result = json.GetValue("value") as JArray;
+
+ Assert.Single(result);
+ Assert.Contains("Friend2", result.ToString());
+ }
+
+ }
+
+ [Fact]
+ public async Task PatchEmployee_WithDeletes_Friends_WithNestedTypes()
+ {
+ //Arrange
+
+ string requestUri = this.BaseAddress + "/convention/Employees(1)/Friends";
+
+ var content = @"{'@odata.context':'" + this.BaseAddress + @"/convention/$metadata#Employees(1)/Friends/$delta', '@odata.type': '#Microsoft.Test.E2E.AspNet.OData.BulkInsert.Friend',
+ 'value':[{ '@odata.removed' : {'reason':'changed'}, 'Id':1, 'Orders@odata.delta' :[{'Id':1,'Price': 10}, {'Id':2,'Price': 20} ] },{ 'Id':2,'Name':'Friend2'}]
+ }";
+
+
+ var requestForPost = new HttpRequestMessage(new HttpMethod("PATCH"), requestUri);
+
+ StringContent stringContent = new StringContent(content: content, encoding: Encoding.UTF8, mediaType: "application/json");
+ requestForPost.Content = stringContent;
+
+ using (HttpResponseMessage response = await this.Client.SendAsync(requestForPost))
+ {
+ var json = response.Content.ReadAsStringAsync().Result;
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ }
+
+ //Assert
+ requestUri = this.BaseAddress + "/convention/Employees(1)/Friends";
+ using (HttpResponseMessage response = await this.Client.GetAsync(requestUri))
+ {
+ response.EnsureSuccessStatusCode();
+
+ var json = await response.Content.ReadAsObject();
+ var result = json.GetValue("value") as JArray;
+
+ Assert.Single(result);
+ Assert.Contains("Friend2", result.ToString());
+ }
+
+ }
+
+ [Fact]
+ public async Task PatchEmployee_WithDeletes_Friends_WithNestedDeletes()
+ {
+ //Arrange
+
+ string requestUri = this.BaseAddress + "/convention/Employees(1)/Friends";
+
+ var content = @"{'@odata.context':'" + this.BaseAddress + @"/convention/$metadata#Employees(1)/Friends/$delta', '@odata.type': '#Microsoft.Test.E2E.AspNet.OData.BulkInsert.Friend',
+ 'value':[{ '@odata.removed' : {'reason':'changed'}, 'Id':1, 'Orders@odata.delta' :[{'@odata.removed' : {'reason':'changed'}, 'Id':1,'Price': 10}, {'Id':2,'Price': 20} ] },{ 'Id':2,'Name':'Friend2'}]
+ }";
+
+
+ var requestForPost = new HttpRequestMessage(new HttpMethod("PATCH"), requestUri);
+
+ StringContent stringContent = new StringContent(content: content, encoding: Encoding.UTF8, mediaType: "application/json");
+ requestForPost.Content = stringContent;
+
+ //Act & Assert
+ using (HttpResponseMessage response = await this.Client.SendAsync(requestForPost))
+ {
+ var json = response.Content.ReadAsStringAsync().Result;
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ }
+
+
+ requestUri = this.BaseAddress + "/convention/Employees(1)/Friends";
+ using (HttpResponseMessage response = await this.Client.GetAsync(requestUri))
+ {
+ response.EnsureSuccessStatusCode();
+
+ var json = await response.Content.ReadAsObject();
+ var result = json.GetValue("value") as JArray;
+
+ Assert.Contains("Friend2", result.ToString());
+ }
+
+ }
+
+ [Fact]
+ public async Task PatchEmployee_WithAdds_Friends_WithAnnotations()
+ {
+ //Arrange
+
+ string requestUri = this.BaseAddress + "/convention/Employees(1)/NewFriends";
+ //{ '@odata.removed' : {'reason':'changed'}, 'Id':1},{ '@odata.removed' : {'reason':'deleted'}, 'Id':2},
+ var content = @"{'@odata.context':'" + this.BaseAddress + @"/convention/$metadata#Employees(1)/NewFriends/$delta',
+ 'value':[{ 'Id':3, 'Age':35, '@NS.Test':1}]
+ }";
+
+
+ var requestForPost = new HttpRequestMessage(new HttpMethod("PATCH"), requestUri);
+
+ requestForPost.Content = new StringContent(content);
+
+ requestForPost.Content.Headers.ContentType= MediaTypeWithQualityHeaderValue.Parse("application/json");
+ // StringContent stringContent = new StringContent(content: content, encoding: Encoding.UTF8, mediaType: "application/json");
+ //requestForPost.Content = stringContent;
+
+ Client.DefaultRequestHeaders.Add("Prefer", @"odata.include-annotations=""*""");
+
+ using (HttpResponseMessage response = await this.Client.SendAsync(requestForPost))
+ {
+ var json = response.Content.ReadAsStringAsync().Result;
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ json.ToString().Contains("$deletedEntity");
+ }
+ }
+
+ [Fact]
+ public async Task PatchEmployee_WithFailedAdds_Friends()
+ {
+ //Arrange
+
+ string requestUri = this.BaseAddress + "/convention/Employees(1)/NewFriends";
+ //{ '@odata.removed' : {'reason':'changed'}, 'Id':1},{ '@odata.removed' : {'reason':'deleted'}, 'Id':2},
+ var content = @"{'@odata.context':'" + this.BaseAddress + @"/convention/$metadata#Employees(1)/NewFriends/$delta',
+ 'value':[{ 'Id':3, 'Age':3, '@NS.Test':1}]
+ }";
+
+
+ var requestForPost = new HttpRequestMessage(new HttpMethod("PATCH"), requestUri);
+
+ StringContent stringContent = new StringContent(content: content, encoding: Encoding.UTF8, mediaType: "application/json");
+ requestForPost.Content = stringContent;
+ Client.DefaultRequestHeaders.Add("Prefer", @"odata.include-annotations=""*""");
+
+ using (HttpResponseMessage response = await this.Client.SendAsync(requestForPost))
+ {
+ var json = response.Content.ReadAsStringAsync().Result;
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ json.ToString().Contains("$deletedEntity");
+ }
+ }
+
+ [Fact]
+ public async Task PatchEmployee_WithFailedDeletes_Friends()
+ {
+ //Arrange
+ string requestUri = this.BaseAddress + "/convention/Employees(2)/NewFriends";
+ //{ '@odata.removed' : {'reason':'changed'}, 'Id':1},{ '@odata.removed' : {'reason':'deleted'}, 'Id':2},
+ var content = @"{'@odata.context':'" + this.BaseAddress + @"/convention/$metadata#Employees(1)/NewFriends/$delta',
+ 'value':[{ '@odata.removed' : {'reason':'changed'}, 'Id':2, '@NS.Test':1}]
+ }";
+
+
+ var requestForPost = new HttpRequestMessage(new HttpMethod("PATCH"), requestUri);
+
+ StringContent stringContent = new StringContent(content: content, encoding: Encoding.UTF8, mediaType: "application/json");
+ requestForPost.Content = stringContent;
+ Client.DefaultRequestHeaders.Add("Prefer", @"odata.include-annotations=""*""");
+
+ using (HttpResponseMessage response = await this.Client.SendAsync(requestForPost))
+ {
+ var json = response.Content.ReadAsStringAsync().Result;
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ Assert.Contains("$delta", json);
+ }
+
+ }
+
+
+ [Fact]
+ public async Task PatchEmployee_WithFailedOperation_WithAnnotations()
+ {
+ //Arrange
+ string requestUri = this.BaseAddress + "/convention/Employees(2)/NewFriends";
+ //{ '@odata.removed' : {'reason':'changed'}, 'Id':1},{ '@odata.removed' : {'reason':'deleted'}, 'Id':2},
+ var content = @"{'@odata.context':'" + this.BaseAddress + @"/convention/$metadata#Employees(2)/NewFriends/$delta',
+ 'value':[{ '@odata.removed' : {'reason':'changed'}, 'Id':2, '@Core.ContentID':3, '@NS.Test2':'testing'}]
+ }";
+
+
+ var requestForPost = new HttpRequestMessage(new HttpMethod("PATCH"), requestUri);
+
+ StringContent stringContent = new StringContent(content: content, encoding: Encoding.UTF8, mediaType: "application/json");
+ requestForPost.Content = stringContent;
+ Client.DefaultRequestHeaders.Add("Prefer", @"odata.include-annotations=""*""");
+
+ using (HttpResponseMessage response = await this.Client.SendAsync(requestForPost))
+ {
+ var json = response.Content.ReadAsStringAsync().Result;
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ var str = json.ToString();
+ Assert.Contains("$delta",str);
+ Assert.Contains("NS.Test2", str);
+ Assert.Contains("Core.DataModificationException", str);
+ }
+
+ }
+
+
+ [Fact]
+ public async Task PatchUntypedEmployee_WithAdds_Friends_Untyped()
+ {
+ //Arrange
+
+ string requestUri = this.BaseAddress + "/convention/UnTypedEmployees";
+ //{ '@odata.removed' : {'reason':'changed'}, 'Id':1},{ '@odata.removed' : {'reason':'deleted'}, 'Id':2},
+ var content = @"{'@odata.context':'" + this.BaseAddress + @"/convention/$metadata#Employees(2)/UnTypedFriends/$delta',
+ 'value':[{ 'Id':3, 'Age':35,}]
+ }";
+
+ content = @"{'@odata.context':'" + this.BaseAddress + @"/convention/$metadata#UnTypedEmployees/$delta',
+ 'value':[{ 'ID':1,'Name':'Employee1',
+ 'UnTypedFriends@odata.delta':[{'Id':1,'Name':'Friend1'},{'Id':2,'Name':'Friend2'}]
+ },
+ { 'ID':2,'Name':'Employee2',
+ 'UnTypedFriends@odata.delta':[{'Id':3,'Name':'Friend3'},{'Id':4,'Name':'Friend4'}]
+ }]
+ }";
+
+
+ var requestForPost = new HttpRequestMessage(new HttpMethod("PATCH"), requestUri);
+
+ StringContent stringContent = new StringContent(content: content, encoding: Encoding.UTF8, mediaType: "application/json");
+ requestForPost.Content = stringContent;
+ Client.DefaultRequestHeaders.Add("Prefer", @"odata.include-annotations=""*""");
+
+ using (HttpResponseMessage response = await this.Client.SendAsync(requestForPost))
+ {
+ var json = response.Content.ReadAsStringAsync().Result;
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ json.ToString().Contains("$deletedEntity");
+ }
+ }
+
+
+ [Fact]
+ public async Task PatchEmployee_WithAdds_Friends_WithNested_Untyped()
+ {
+ //Arrange
+
+ string requestUri = this.BaseAddress + "/convention/Employees(1)/UnTypedFriends";
+ //{ '@odata.removed' : {'reason':'changed'}, 'Id':1},{ '@odata.removed' : {'reason':'deleted'}, 'Id':2},
+ var content = @"{'@odata.context':'" + this.BaseAddress + @"/convention/$metadata#Employees(1)/UnTypedFriends/$delta',
+ 'value':[{ 'Id':2, 'Name': 'Friend007', 'Age':35,'Address@odata.delta':{'Id':1, 'Street' : 'Abc 123'}, '@NS.Test':1}]
+ }";
+
+
+ var requestForPost = new HttpRequestMessage(new HttpMethod("PATCH"), requestUri);
+
+ StringContent stringContent = new StringContent(content: content, encoding: Encoding.UTF8, mediaType: "application/json");
+ requestForPost.Content = stringContent;
+ Client.DefaultRequestHeaders.Add("Prefer", @"odata.include-annotations=""*""");
+
+ using (HttpResponseMessage response = await this.Client.SendAsync(requestForPost))
+ {
+ var json = response.Content.ReadAsStringAsync().Result;
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ json.ToString().Contains("$delta");
+ json.ToString().Contains("@NS.Test");
+ }
+
+ }
+
+
+ [Fact]
+ public async Task PatchEmployee_WithAdds_Friends_WithAnnotations_Untyped()
+ {
+ //Arrange
+
+ string requestUri = this.BaseAddress + "/convention/Employees(2)/UnTypedFriends";
+ //{ '@odata.removed' : {'reason':'changed'}, 'Id':1},{ '@odata.removed' : {'reason':'deleted'}, 'Id':2},
+ var content = @"{'@odata.context':'" + this.BaseAddress + @"/convention/$metadata#Employees(2)/UnTypedFriends/$delta',
+ 'value':[{ 'Id':2, 'Age':35, '@NS.Test':1}]
+ }";
+
+
+ var requestForPost = new HttpRequestMessage(new HttpMethod("PATCH"), requestUri);
+
+ StringContent stringContent = new StringContent(content: content, encoding: Encoding.UTF8, mediaType: "application/json");
+ requestForPost.Content = stringContent;
+ Client.DefaultRequestHeaders.Add("Prefer", @"odata.include-annotations=""*""");
+
+ using (HttpResponseMessage response = await this.Client.SendAsync(requestForPost))
+ {
+ var json = response.Content.ReadAsStringAsync().Result;
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ json.ToString().Contains("$delta");
+ json.ToString().Contains("@NS.Test");
+ }
+ }
+
+ [Fact]
+ public async Task PatchEmployee_WithFailedAdds_Friends_Untyped()
+ {
+ //Arrange
+
+ string requestUri = this.BaseAddress + "/convention/Employees(3)/UnTypedFriends";
+ //{ '@odata.removed' : {'reason':'changed'}, 'Id':1},{ '@odata.removed' : {'reason':'deleted'}, 'Id':2},
+ var content = @"{'@odata.context':'" + this.BaseAddress + @"/convention/$metadata#Employees(3)/UnTypedFriends/$delta',
+ 'value':[{ 'Id':3, 'Age':3, '@NS.Test':1}]
+ }";
+
+
+ var requestForPost = new HttpRequestMessage(new HttpMethod("PATCH"), requestUri);
+
+ StringContent stringContent = new StringContent(content: content, encoding: Encoding.UTF8, mediaType: "application/json");
+ requestForPost.Content = stringContent;
+ Client.DefaultRequestHeaders.Add("Prefer", @"odata.include-annotations=""*""");
+
+ using (HttpResponseMessage response = await this.Client.SendAsync(requestForPost))
+ {
+ var json = response.Content.ReadAsStringAsync().Result;
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ json.ToString().Contains("$deletedEntity");
+ }
+ }
+
+ [Fact]
+ public async Task PatchEmployee_WithFailedDeletes_Friends_Untyped()
+ {
+ //Arrange
+ string requestUri = this.BaseAddress + "/convention/Employees(3)/UnTypedFriends";
+ //{ '@odata.removed' : {'reason':'changed'}, 'Id':1},{ '@odata.removed' : {'reason':'deleted'}, 'Id':2},
+ var content = @"{'@odata.context':'" + this.BaseAddress + @"/convention/$metadata#Employees(3)/UnTypedFriends/$delta',
+ 'value':[{ '@odata.removed' : {'reason':'changed'}, 'Id':5, '@NS.Test':1}]
+ }";
+
+
+ var requestForPost = new HttpRequestMessage(new HttpMethod("PATCH"), requestUri);
+
+ StringContent stringContent = new StringContent(content: content, encoding: Encoding.UTF8, mediaType: "application/json");
+ requestForPost.Content = stringContent;
+ Client.DefaultRequestHeaders.Add("Prefer", @"odata.include-annotations=""*""");
+
+ using (HttpResponseMessage response = await this.Client.SendAsync(requestForPost))
+ {
+ var json = response.Content.ReadAsStringAsync().Result;
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ Assert.Contains("@Core.DataModificationException", json.ToString());
+ Assert.Contains("@NS.Test", json.ToString());
+ }
+
+ }
+
+
+ [Fact]
+ public async Task PatchEmployee_WithFailedOperation_WithAnnotations_Untyped()
+ {
+ //Arrange
+ string requestUri = this.BaseAddress + "/convention/Employees(3)/UnTypedFriends";
+ //{ '@odata.removed' : {'reason':'changed'}, 'Id':1},{ '@odata.removed' : {'reason':'deleted'}, 'Id':2},
+ var content = @"{'@odata.context':'" + this.BaseAddress + @"/convention/$metadata#Employees(3)/UnTypedFriends/$delta',
+ 'value':[{ '@odata.removed' : {'reason':'changed'}, 'Id':5, '@Core.ContentID':3, '@NS.Test2':'testing'}]
+ }";
+
+
+ var requestForPost = new HttpRequestMessage(new HttpMethod("PATCH"), requestUri);
+
+ StringContent stringContent = new StringContent(content: content, encoding: Encoding.UTF8, mediaType: "application/json");
+ requestForPost.Content = stringContent;
+ Client.DefaultRequestHeaders.Add("Prefer", @"odata.include-annotations=""*""");
+
+ using (HttpResponseMessage response = await this.Client.SendAsync(requestForPost))
+ {
+ var json = response.Content.ReadAsStringAsync().Result;
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ var str = json.ToString();
+ Assert.Contains("$delta", str);
+ Assert.Contains("NS.Test2", str);
+ Assert.Contains("Core.DataModificationException", str);
+ Assert.Contains("Core.ContentID", str);
+ }
+
+ }
+
+ [Fact]
+ public async Task PatchEmployee_WithUpdates_Employees()
+ {
+ //Arrange
+
+ string requestUri = this.BaseAddress + "/convention/Employees";
+
+ var content = @"{'@odata.context':'"+ this.BaseAddress + @"/convention/$metadata#Employees/$delta',
+ 'value':[{ '@odata.type': '#Microsoft.Test.E2E.AspNet.OData.BulkInsert.Employee', 'ID':1,'Name':'Employee1',
+ 'Friends@odata.delta':[{'Id':1,'Name':'Friend1',
+ 'Orders@odata.delta' :[{'Id':1,'Price': 10}, {'Id':2,'Price': 20} ] },{'Id':2,'Name':'Friend2'}]
+ },
+ { '@odata.type': '#Microsoft.Test.E2E.AspNet.OData.BulkInsert.Employee', 'ID':2,'Name':'Employee2',
+ 'Friends@odata.delta':[{'Id':3,'Name':'Friend3',
+ 'Orders@odata.delta' :[{'Id':3,'Price': 30}, {'Id':4,'Price': 40} ]},{'Id':4,'Name':'Friend4'}]
+ }]
+ }";
+
+ var requestForPost = new HttpRequestMessage(new HttpMethod("PATCH"), requestUri);
+
+ StringContent stringContent = new StringContent(content: content, encoding: Encoding.UTF8, mediaType: "application/json");
+ requestForPost.Content = stringContent;
+
+ using (HttpResponseMessage response = await this.Client.SendAsync(requestForPost))
+ {
+ var json = response.Content.ReadAsStringAsync().Result;
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ }
+
+ //Assert
+ requestUri = this.BaseAddress + "/convention/Employees(1)/Friends";
+ using (HttpResponseMessage response = await this.Client.GetAsync(requestUri))
+ {
+ response.EnsureSuccessStatusCode();
+
+ var json = response.Content.ReadAsStringAsync().Result;
+
+ Assert.Contains("Friend1", json.ToString());
+ Assert.Contains("Friend2", json.ToString());
+ }
+
+ requestUri = this.BaseAddress + "/convention/Employees(2)/Friends";
+ using (HttpResponseMessage response = await this.Client.GetAsync(requestUri))
+ {
+ response.EnsureSuccessStatusCode();
+
+ var json = response.Content.ReadAsStringAsync().Result;
+
+ Assert.Contains("Friend3", json.ToString());
+ Assert.Contains("Friend4", json.ToString());
+ }
+ }
+
+
+ [Fact]
+ public async Task PatchEmployee_WithDelete()
+ {
+ //Arrange
+
+ string requestUri = this.BaseAddress + "/convention/Employees(1)";
+
+ var content = @"{
+ 'Name':'Sql' ,
+ 'Friends@odata.delta':[{ '@odata.removed' : {'reason':'changed'}, 'Id':1}]
+ }";
+
+ var requestForPost = new HttpRequestMessage(new HttpMethod("PATCH"), requestUri);
+
+ StringContent stringContent = new StringContent(content: content, encoding: Encoding.UTF8, mediaType: "application/json");
+ requestForPost.Content = stringContent;
+
+ using (HttpResponseMessage response = await this.Client.SendAsync(requestForPost))
+ {
+ var json = response.Content.ReadAsStringAsync().Result;
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ }
+
+ //Assert
+ requestUri = this.BaseAddress + "/convention/Employees(1)/Friends";
+ using (HttpResponseMessage response = await this.Client.GetAsync(requestUri))
+ {
+ response.EnsureSuccessStatusCode();
+
+ var json = await response.Content.ReadAsObject();
+ var result = json.GetValue("value") as JArray;
+
+ Assert.Single(result);
+ Assert.DoesNotContain("Test0", result.ToString());
+ }
+ }
+
+ [Fact]
+ public async Task PatchEmployee_WithODataBind()
+ {
+ //Arrange
+
+ string requestUri = this.BaseAddress + "/convention/Employees(1)";
+
+ var content = @"{
+ 'Name':'Bind1' ,
+ 'Friends@odata.bind':['Friends(3)']
+ }";
+
+ var requestForPost = new HttpRequestMessage(new HttpMethod("PATCH"), requestUri);
+
+ StringContent stringContent = new StringContent(content: content, encoding: Encoding.UTF8, mediaType: "application/json");
+ requestForPost.Content = stringContent;
+
+ //Act & Assert
+ using (HttpResponseMessage response = await this.Client.SendAsync(requestForPost))
+ {
+ var json = response.Content.ReadAsStringAsync().Result;
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ }
+
+
+
+ }
+
+
+ [Fact]
+ public async Task PatchEmployee_WithAddUpdateAndDelete()
+ {
+ //Arrange
+
+ string requestUri = this.BaseAddress + "/convention/Employees(1)";
+
+ var content = @"{
+ 'Name':'Sql' ,
+ 'Friends@odata.delta':[{ '@odata.removed' : {'reason':'changed'}, 'Id':1},{'Id':2,'Name':'Test3'},{'Id':3,'Name':'Test4'}]
+ }";
+
+ var requestForPost = new HttpRequestMessage(new HttpMethod("PATCH"), requestUri);
+
+ StringContent stringContent = new StringContent(content: content, encoding: Encoding.UTF8, mediaType: "application/json");
+ requestForPost.Content = stringContent;
+
+ using (HttpResponseMessage response = await this.Client.SendAsync(requestForPost))
+ {
+ var json = response.Content.ReadAsStringAsync().Result;
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ }
+
+ //Assert
+ requestUri = this.BaseAddress + "/convention/Employees(1)/Friends";
+ using (HttpResponseMessage response = await this.Client.GetAsync(requestUri))
+ {
+ response.EnsureSuccessStatusCode();
+
+ var json = await response.Content.ReadAsObject();
+ var result = json.GetValue("value") as JArray;
+
+ Assert.Equal(2, result.Count);
+ Assert.DoesNotContain("Test0", result.ToString());
+ Assert.Contains("Test3", result.ToString());
+ Assert.Contains("Test4", result.ToString());
+ }
+ }
+
+
+ [Fact]
+ public async Task PatchEmployee_WithMultipleUpdatesinOrder1()
+ {
+ //Arrange
+
+ string requestUri = this.BaseAddress + "/convention/Employees(1)";
+
+ var content = @"{
+ 'Name':'Sql' ,
+ 'Friends@odata.delta':[{ '@odata.removed' : {'reason':'changed'}, 'Id':1},{'Id':1,'Name':'Test_1'},{'Id':2,'Name':'Test3'},{'Id':3,'Name':'Test4'}]
+ }";
+
+ var requestForPost = new HttpRequestMessage(new HttpMethod("PATCH"), requestUri);
+
+ StringContent stringContent = new StringContent(content: content, encoding: Encoding.UTF8, mediaType: "application/json");
+ requestForPost.Content = stringContent;
+
+ using (HttpResponseMessage response = await this.Client.SendAsync(requestForPost))
+ {
+ var json = response.Content.ReadAsStringAsync().Result;
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ }
+
+ //Assert
+ requestUri = this.BaseAddress + "/convention/Employees(1)/Friends";
+ using (HttpResponseMessage response = await this.Client.GetAsync(requestUri))
+ {
+ response.EnsureSuccessStatusCode();
+
+ var json = await response.Content.ReadAsObject();
+ var result = json.GetValue("value") as JArray;
+
+ Assert.Equal(3, result.Count);
+ Assert.DoesNotContain("Test0", result.ToString());
+ Assert.Contains("Test_1", result.ToString());
+ Assert.Contains("Test3", result.ToString());
+ Assert.Contains("Test4", result.ToString());
+ }
+ }
+
+ [Fact]
+ public async Task PatchEmployee_WithMultipleUpdatesinOrder2()
+ {
+ //Arrange
+
+ string requestUri = this.BaseAddress + "/convention/Employees(1)";
+
+ var content = @"{
+ 'Name':'Sql' ,
+ 'Friends@odata.delta':[{ '@odata.removed' : {'reason':'changed'}, 'Id':1},{'Id':1,'Name':'Test_1'},{'Id':2,'Name':'Test3'},{'Id':3,'Name':'Test4'},{ '@odata.removed' : {'reason':'changed'}, 'Id':1}]
+ }";
+
+ var requestForPost = new HttpRequestMessage(new HttpMethod("PATCH"), requestUri);
+
+ StringContent stringContent = new StringContent(content: content, encoding: Encoding.UTF8, mediaType: "application/json");
+ requestForPost.Content = stringContent;
+
+ using (HttpResponseMessage response = await this.Client.SendAsync(requestForPost))
+ {
+ var json = response.Content.ReadAsStringAsync().Result;
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ }
+
+ //Assert
+ requestUri = this.BaseAddress + "/convention/Employees(1)/Friends";
+ using (HttpResponseMessage response = await this.Client.GetAsync(requestUri))
+ {
+ response.EnsureSuccessStatusCode();
+
+ var json = await response.Content.ReadAsObject();
+ var result = json.GetValue("value") as JArray;
+
+ Assert.Equal(2, result.Count);
+ Assert.DoesNotContain("Test0", result.ToString());
+ Assert.DoesNotContain("Test_1", result.ToString());
+ Assert.Contains("Test3", result.ToString());
+ Assert.Contains("Test4", result.ToString());
+ }
+ }
+
+
+ [Fact]
+ public async Task PatchCompanies_WithUpdates_ODataId()
+ {
+ //Arrange
+
+ string requestUri = this.BaseAddress + "/convention/Companies";
+
+ var content = @"{'@odata.context':'" + this.BaseAddress + @"/convention/$metadata#Companies/$delta',
+ 'value':[{ '@odata.type': '#Microsoft.Test.E2E.AspNet.OData.BulkInsert.Company', 'Id':1,'Name':'Company01',
+ 'OverdueOrders@odata.delta':[{'@odata.id':'Employees(1)/NewFriends(1)/NewOrders(1)', 'Quantity': 9}]
+
+ }]
+ }";
+
+
+ var requestForPost = new HttpRequestMessage(new HttpMethod("PATCH"), requestUri);
+
+ StringContent stringContent = new StringContent(content: content, encoding: Encoding.UTF8, mediaType: "application/json");
+ requestForPost.Content = stringContent;
+
+ //Act & Assert
+ using (HttpResponseMessage response = await this.Client.SendAsync(requestForPost))
+ {
+ var json = response.Content.ReadAsStringAsync().Result;
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ }
+
+
+ }
+
+ [Fact]
+ public async Task PatchCompanies_WithUpdates_ODataId_WithCast()
+ {
+ //Arrange
+
+ string requestUri = this.BaseAddress + "/convention/Companies";
+
+ var content = @"{'@odata.context':'" + this.BaseAddress + @"/convention/$metadata#Companies/$delta',
+ 'value':[{ '@odata.type': '#Microsoft.Test.E2E.AspNet.OData.BulkInsert.Company', 'Id':1,'Name':'Company02',
+ 'MyOverdueOrders@odata.delta':[{'@odata.id':'Employees(2)/NewFriends(2)/Microsoft.Test.E2E.AspNet.OData.BulkInsert.MyNewFriend/MyNewOrders(2)', 'Quantity': 9}]
+
+ }]
+ }";
+
+
+ var requestForPost = new HttpRequestMessage(new HttpMethod("PATCH"), requestUri);
+
+ StringContent stringContent = new StringContent(content: content, encoding: Encoding.UTF8, mediaType: "application/json");
+ requestForPost.Content = stringContent;
+
+ //Act & Assert
+ using (HttpResponseMessage response = await this.Client.SendAsync(requestForPost))
+ {
+ var json = response.Content.ReadAsStringAsync().Result;
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ }
+
+
+ }
+
+
+ [Fact]
+ public async Task PatchUntypedEmployee_WithOdataId()
+ {
+ //Arrange
+
+ string requestUri = this.BaseAddress + "/convention/UnTypedEmployees";
+
+ var content = @"{'@odata.context':'" + this.BaseAddress + @"/convention/$metadata#UnTypedEmployees/$delta',
+ 'value':[{ 'ID':1,'Name':'Employeeabcd',
+ 'UnTypedFriends@odata.delta':[{'@odata.id':'UnTypedEmployees(1)/UnTypedFriends(1)', 'Name':'abcd'}]
+ }]
+ }";
+
+ var requestForPost = new HttpRequestMessage(new HttpMethod("PATCH"), requestUri);
+
+ StringContent stringContent = new StringContent(content: content, encoding: Encoding.UTF8, mediaType: "application/json");
+ requestForPost.Content = stringContent;
+ Client.DefaultRequestHeaders.Add("Prefer", @"odata.include-annotations=""*""");
+
+ //Act & Assert
+ using (HttpResponseMessage response = await this.Client.SendAsync(requestForPost))
+ {
+ var json = response.Content.ReadAsStringAsync().Result;
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ json.ToString().Contains("$deletedEntity");
+ }
+ }
+
+ [Fact]
+ public async Task PostCompany_WithODataId()
+ {
+ //Arrange
+
+ string requestUri = this.BaseAddress + "/convention/Companies";
+
+ var content = @"{'Id':3,'Name':'Company03',
+ 'OverdueOrders':[{'@odata.id':'Employees(1)/NewFriends(1)/NewOrders(1)'}]
+
+
+ }";
+
+ var requestForPost = new HttpRequestMessage(new HttpMethod("POST"), requestUri);
+
+ StringContent stringContent = new StringContent(content: content, encoding: Encoding.UTF8, mediaType: "application/json");
+ requestForPost.Content = stringContent;
+
+ //Act & Assert
+ using (HttpResponseMessage response = await this.Client.SendAsync(requestForPost))
+ {
+ var json = response.Content.ReadAsStringAsync().Result;
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ }
+
+ }
+
+
+ [Fact]
+ public async Task PostCompany_WithODataId_AndWithout()
+ {
+ //Arrange
+
+ string requestUri = this.BaseAddress + "/convention/Companies";
+
+ var content = @"{'Id':4,'Name':'Company04',
+ 'OverdueOrders':[{'@odata.id':'Employees(1)/NewFriends(1)/NewOrders(1)'},{Price:30}]
+
+
+ }";
+
+ var requestForPost = new HttpRequestMessage(new HttpMethod("POST"), requestUri);
+
+ StringContent stringContent = new StringContent(content: content, encoding: Encoding.UTF8, mediaType: "application/json");
+ requestForPost.Content = stringContent;
+
+ //Act & Assert
+ using (HttpResponseMessage response = await this.Client.SendAsync(requestForPost))
+ {
+ var json = response.Content.ReadAsStringAsync().Result;
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ }
+
+ }
+
+
+
+ #endregion
+
+ }
+}
\ No newline at end of file
diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/BulkOperation/BulkOperationPatchHandlers.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/BulkOperation/BulkOperationPatchHandlers.cs
new file mode 100644
index 0000000000..8e53bc8f27
--- /dev/null
+++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/BulkOperation/BulkOperationPatchHandlers.cs
@@ -0,0 +1,1316 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.AspNet.OData;
+using Microsoft.OData.Edm;
+using Microsoft.Test.E2E.AspNet.OData.BulkInsert;
+
+namespace Microsoft.Test.E2E.AspNet.OData.BulkOperation
+{
+ public class APIHandlerFactory : ODataAPIHandlerFactory
+ {
+ Employee employee;
+ public APIHandlerFactory()
+ {
+
+ }
+
+ public APIHandlerFactory(Employee employee)
+ {
+ this.employee = employee;
+ }
+
+ public override IODataAPIHandler GetHandler(NavigationPath navigationPath)
+ {
+ if(navigationPath != null)
+ {
+ var pathItems = navigationPath.GetNavigationPathItems();
+
+ if(pathItems == null)
+ {
+ switch (navigationPath.NavigationPathName)
+ {
+ case "Employees":
+ case "Employee":
+ return new EmployeeAPIHandler();
+ case "NewFriend":
+ return new NewFriendAPIHandler(employee);
+ case "Company":
+ return new CompanyAPIHandler();
+ default:
+ return null;
+ }
+ }
+
+ int cnt = 0;
+
+ switch (pathItems[cnt].Name)
+ {
+ case "Employees":
+ {
+ Employee employee;
+ string msg;
+ if ((new EmployeeAPIHandler().TryGet(pathItems[cnt].KeyProperties, out employee, out msg)) == ODataAPIResponseStatus.Success)
+ {
+ return GetNestedHandlerForEmployee(pathItems, cnt, employee);
+ }
+ }
+ return null;
+
+ default:
+ return null;
+
+ }
+
+ }
+
+ return null;
+ }
+
+ private static IODataAPIHandler GetNestedHandlerForEmployee(PathItem[] pathItems, int cnt, Employee employee)
+ {
+ cnt++;
+ if(pathItems.Length <= cnt)
+ {
+ return null;
+ }
+
+ switch (pathItems[cnt].Name)
+ {
+ case "NewFriends":
+ if (pathItems[cnt].IsCastType)
+ {
+ if (pathItems[cnt].CastTypeName == "Microsoft.Test.E2E.AspNet.OData.BulkInsert.MyNewFriend")
+ {
+ MyNewFriend friend = employee.NewFriends.FirstOrDefault(x => x.Id == (int)pathItems[cnt].KeyProperties["Id"]) as MyNewFriend;
+
+ if (friend != null)
+ {
+ switch (pathItems[++cnt].Name)
+ {
+ case "MyNewOrders":
+ return new MyNewOrderAPIHandler(friend);
+
+ default:
+ return null;
+
+ }
+ }
+ }
+ }
+ else
+ {
+ NewFriend friend = employee.NewFriends.FirstOrDefault(x => x.Id == (int)pathItems[cnt].KeyProperties["Id"]);
+
+ if (friend != null)
+ {
+ switch (pathItems[++cnt].Name)
+ {
+ case "NewOrders":
+ return new NewOrderAPIHandler(friend);
+
+ default:
+ return null;
+
+ }
+ }
+ }
+
+ return null;
+
+ default:
+ return null;
+
+ }
+ }
+ }
+
+ public class TypelessAPIHandlerFactory : ODataEdmAPIHandlerFactory
+ {
+ IEdmEntityType entityType;
+ IEdmStructuredObject employee;
+
+ public TypelessAPIHandlerFactory(IEdmEntityType entityType)
+ {
+ this.entityType = entityType;
+ }
+
+ public TypelessAPIHandlerFactory(IEdmEntityType entityType, IEdmStructuredObject employee)
+ {
+ this.entityType = entityType;
+ this.employee = employee;
+ }
+
+ public override EdmODataAPIHandler GetHandler(NavigationPath navigationPath)
+ {
+ if (navigationPath != null)
+ {
+ var pathItems = navigationPath.GetNavigationPathItems();
+ int cnt = 0;
+
+ if (pathItems == null)
+ {
+ switch (navigationPath.NavigationPathName)
+ {
+ case "UnTypedEmployee":
+ return new EmployeeEdmAPIHandler(entityType);
+ case "UnTypedFriend":
+ return new FriendTypelessAPIHandler(employee, entityType);
+
+ default:
+ return null;
+ }
+ }
+
+ switch (pathItems[cnt].Name)
+ {
+ case "UnTypedEmployees":
+ {
+ IEdmStructuredObject employee;
+ string msg;
+ if ((new EmployeeEdmAPIHandler(entityType).TryGet(pathItems[cnt].KeyProperties, out employee, out msg)) == ODataAPIResponseStatus.Success)
+ {
+ cnt++;
+
+ if (cnt x.Id == (int)pathItems[cnt].KeyProperties["Id"]) as MyNewFriend;
+
+ if (friend != null)
+ {
+ switch (pathItems[++cnt].Name)
+ {
+ case "MyNewOrders":
+ return new MyNewOrderAPIHandler(friend);
+
+ default:
+ return null;
+
+ }
+ }
+ }
+ }
+ else
+ {
+ NewFriend friend = employee.NewFriends.FirstOrDefault(x => x.Id == (int)pathItems[cnt].KeyProperties["Id"]);
+
+ if (friend != null)
+ {
+ switch (pathItems[++cnt].Name)
+ {
+ case "NewOrders":
+ return new NewOrderAPIHandler(friend);
+
+ default:
+ return null;
+
+ }
+ }
+ }
+
+ return null;
+
+ default:
+ return null;
+
+ }
+ }
+ }
+
+
+ public class CompanyAPIHandler : ODataAPIHandler
+ {
+ public override ODataAPIResponseStatus TryCreate(IDictionary keyValues, out Company createdObject, out string errorMessage)
+ {
+ createdObject = null;
+ errorMessage = string.Empty;
+
+ try
+ {
+ createdObject = new Company();
+ CompanyController.Companies.Add(createdObject);
+
+ return ODataAPIResponseStatus.Success;
+ }
+ catch (Exception ex)
+ {
+ errorMessage = ex.Message;
+
+ return ODataAPIResponseStatus.Failure;
+ }
+ }
+
+ public override ODataAPIResponseStatus TryDelete(IDictionary keyValues, out string errorMessage)
+ {
+ errorMessage = string.Empty;
+
+ try
+ {
+ var id = keyValues.First().Value.ToString();
+ var company = CompanyController.Companies.First(x => x.Id == Int32.Parse(id));
+
+ CompanyController.Companies.Remove(company);
+
+ return ODataAPIResponseStatus.Success;
+ }
+ catch (Exception ex)
+ {
+ errorMessage = ex.Message;
+
+ return ODataAPIResponseStatus.Failure;
+ }
+ }
+
+ public override ODataAPIResponseStatus TryGet(IDictionary keyValues, out Company originalObject, out string errorMessage)
+ {
+ ODataAPIResponseStatus status = ODataAPIResponseStatus.Success;
+ errorMessage = string.Empty;
+ originalObject = null;
+
+ try
+ {
+ var id = keyValues["Id"].ToString();
+ originalObject = CompanyController.Companies.First(x => x.Id == Int32.Parse(id));
+
+
+ if (originalObject == null)
+ {
+ status = ODataAPIResponseStatus.NotFound;
+ }
+
+ }
+ catch (Exception ex)
+ {
+ status = ODataAPIResponseStatus.Failure;
+ errorMessage = ex.Message;
+ }
+
+ return status;
+ }
+
+ public override IODataAPIHandler GetNestedHandler(Company parent, string navigationPropertyName)
+ {
+ switch (navigationPropertyName)
+ {
+ case "OverdueOrders":
+ return new OverdueOrderAPIHandler(parent);
+ case "MyOverdueOrders":
+ return new MyOverdueOrderAPIHandler(parent);
+ default:
+ return null;
+ }
+
+ }
+ }
+
+ public class OverdueOrderAPIHandler : ODataAPIHandler
+ {
+ Company parent;
+
+ public OverdueOrderAPIHandler(Company parent)
+ {
+ this.parent = parent;
+ }
+
+ public override ODataAPIResponseStatus TryCreate(IDictionary keyValues, out NewOrder createdObject, out string errorMessage)
+ {
+ createdObject = null;
+ errorMessage = string.Empty;
+
+ try
+ {
+ createdObject = new NewOrder();
+ parent.OverdueOrders.Add(createdObject);
+
+ return ODataAPIResponseStatus.Success;
+ }
+ catch (Exception ex)
+ {
+ errorMessage = ex.Message;
+
+ return ODataAPIResponseStatus.Failure;
+ }
+ }
+
+ public override ODataAPIResponseStatus TryDelete(IDictionary keyValues, out string errorMessage)
+ {
+ errorMessage = string.Empty;
+
+ try
+ {
+ var id = keyValues.First().Value.ToString();
+ var newOrders = CompanyController.OverdueOrders.First(x => x.Id == Int32.Parse(id));
+
+ parent.OverdueOrders.Remove(newOrders);
+
+ return ODataAPIResponseStatus.Success;
+ }
+ catch (Exception ex)
+ {
+ errorMessage = ex.Message;
+
+ return ODataAPIResponseStatus.Failure;
+ }
+ }
+
+ public override ODataAPIResponseStatus TryGet(IDictionary keyValues, out NewOrder originalObject, out string errorMessage)
+ {
+ ODataAPIResponseStatus status = ODataAPIResponseStatus.Success;
+ errorMessage = string.Empty;
+ originalObject = null;
+
+ try
+ {
+ var id = keyValues["Id"].ToString();
+ originalObject = parent.OverdueOrders.FirstOrDefault(x => x.Id == Int32.Parse(id));
+
+
+ if (originalObject == null)
+ {
+ status = ODataAPIResponseStatus.NotFound;
+ }
+
+ }
+ catch (Exception ex)
+ {
+ status = ODataAPIResponseStatus.Failure;
+ errorMessage = ex.Message;
+ }
+
+ return status;
+ }
+
+ public override IODataAPIHandler GetNestedHandler(NewOrder parent, string navigationPropertyName)
+ {
+ switch (navigationPropertyName)
+ {
+
+ default:
+ return null;
+ }
+
+ }
+ }
+
+ public class MyOverdueOrderAPIHandler : ODataAPIHandler
+ {
+ Company parent;
+
+ public MyOverdueOrderAPIHandler(Company parent)
+ {
+ this.parent = parent;
+ }
+
+ public override ODataAPIResponseStatus TryCreate(IDictionary keyValues, out MyNewOrder createdObject, out string errorMessage)
+ {
+ createdObject = null;
+ errorMessage = string.Empty;
+
+ try
+ {
+ createdObject = new MyNewOrder();
+ parent.MyOverdueOrders.Add(createdObject);
+
+ return ODataAPIResponseStatus.Success;
+ }
+ catch (Exception ex)
+ {
+ errorMessage = ex.Message;
+
+ return ODataAPIResponseStatus.Failure;
+ }
+ }
+
+ public override ODataAPIResponseStatus TryDelete(IDictionary keyValues, out string errorMessage)
+ {
+ errorMessage = string.Empty;
+
+ try
+ {
+ var id = keyValues.First().Value.ToString();
+ var newOrders = CompanyController.MyOverdueOrders.First(x => x.Id == Int32.Parse(id));
+
+ parent.MyOverdueOrders.Remove(newOrders);
+
+ return ODataAPIResponseStatus.Success;
+ }
+ catch (Exception ex)
+ {
+ errorMessage = ex.Message;
+
+ return ODataAPIResponseStatus.Failure;
+ }
+ }
+
+ public override ODataAPIResponseStatus TryGet(IDictionary keyValues, out MyNewOrder originalObject, out string errorMessage)
+ {
+ ODataAPIResponseStatus status = ODataAPIResponseStatus.Success;
+ errorMessage = string.Empty;
+ originalObject = null;
+
+ try
+ {
+ var id = keyValues["Id"].ToString();
+ originalObject = parent.MyOverdueOrders.FirstOrDefault(x => x.Id == Int32.Parse(id));
+
+
+ if (originalObject == null)
+ {
+ status = ODataAPIResponseStatus.NotFound;
+ }
+
+ }
+ catch (Exception ex)
+ {
+ status = ODataAPIResponseStatus.Failure;
+ errorMessage = ex.Message;
+ }
+
+ return status;
+ }
+
+ public override IODataAPIHandler GetNestedHandler(MyNewOrder parent, string navigationPropertyName)
+ {
+ switch (navigationPropertyName)
+ {
+
+ default:
+ return null;
+ }
+
+ }
+ }
+
+
+ public class EmployeeAPIHandler : ODataAPIHandler
+ {
+ public override ODataAPIResponseStatus TryCreate(IDictionary keyValues, out Employee createdObject, out string errorMessage)
+ {
+ createdObject = null;
+ errorMessage = string.Empty;
+
+ try
+ {
+ createdObject = new Employee();
+ EmployeesController.Employees.Add(createdObject);
+
+ return ODataAPIResponseStatus.Success;
+ }
+ catch (Exception ex)
+ {
+ errorMessage = ex.Message;
+
+ return ODataAPIResponseStatus.Failure;
+ }
+ }
+
+ public override ODataAPIResponseStatus TryDelete(IDictionary keyValues, out string errorMessage)
+ {
+ errorMessage = string.Empty;
+
+ try
+ {
+ var id = keyValues.First().Value.ToString();
+ var customer = EmployeesController.Employees.First(x => x.ID == Int32.Parse(id));
+
+ EmployeesController.Employees.Remove(customer);
+
+ return ODataAPIResponseStatus.Success;
+ }
+ catch (Exception ex)
+ {
+ errorMessage = ex.Message;
+
+ return ODataAPIResponseStatus.Failure;
+ }
+ }
+
+ public override ODataAPIResponseStatus TryGet(IDictionary keyValues, out Employee originalObject, out string errorMessage)
+ {
+ ODataAPIResponseStatus status = ODataAPIResponseStatus.Success;
+ errorMessage = string.Empty;
+ originalObject = null;
+
+ try
+ {
+ var id = keyValues["ID"].ToString();
+ originalObject = EmployeesController.Employees.First(x => x.ID == Int32.Parse(id));
+
+
+ if (originalObject == null)
+ {
+ status = ODataAPIResponseStatus.NotFound;
+ }
+
+ }
+ catch (Exception ex)
+ {
+ status = ODataAPIResponseStatus.Failure;
+ errorMessage = ex.Message;
+ }
+
+ return status;
+ }
+
+ public override IODataAPIHandler GetNestedHandler(Employee parent, string navigationPropertyName)
+ {
+ switch (navigationPropertyName)
+ {
+ case "Friends":
+ return new FriendAPIHandler(parent);
+ case "NewFriends":
+ return new NewFriendAPIHandler(parent);
+ default:
+ return null;
+ }
+
+ }
+ }
+
+ public class FriendAPIHandler : ODataAPIHandler
+ {
+ Employee employee;
+ public FriendAPIHandler(Employee employee)
+ {
+ this.employee = employee;
+ }
+
+ public override ODataAPIResponseStatus TryCreate(IDictionary keyValues, out Friend createdObject, out string errorMessage)
+ {
+ createdObject = null;
+ errorMessage = string.Empty;
+
+ try
+ {
+ createdObject = new Friend();
+ employee.Friends.Add(createdObject);
+
+ return ODataAPIResponseStatus.Success;
+ }
+ catch (Exception ex)
+ {
+ errorMessage = ex.Message;
+
+ return ODataAPIResponseStatus.Failure;
+ }
+ }
+
+ public override ODataAPIResponseStatus TryDelete(IDictionary keyValues, out string errorMessage)
+ {
+ errorMessage = string.Empty;
+
+ try
+ {
+ var id = keyValues.First().Value.ToString();
+ var friend = employee.Friends.FirstOrDefault(x => x.Id == Int32.Parse(id));
+
+ employee.Friends.Remove(friend);
+
+ return ODataAPIResponseStatus.Success;
+ }
+ catch (Exception ex)
+ {
+ errorMessage = ex.Message;
+
+ return ODataAPIResponseStatus.Failure;
+ }
+ }
+
+ public override ODataAPIResponseStatus TryGet(IDictionary keyValues, out Friend originalObject, out string errorMessage)
+ {
+ ODataAPIResponseStatus status = ODataAPIResponseStatus.Success;
+ errorMessage = string.Empty;
+ originalObject = null;
+
+ try
+ {
+ var id = keyValues["Id"].ToString();
+ originalObject = employee.Friends.FirstOrDefault(x => x.Id == Int32.Parse(id));
+
+
+ if (originalObject == null)
+ {
+ status = ODataAPIResponseStatus.NotFound;
+ }
+
+ }
+ catch (Exception ex)
+ {
+ status = ODataAPIResponseStatus.Failure;
+ errorMessage = ex.Message;
+ }
+
+ return status;
+ }
+
+ public override IODataAPIHandler GetNestedHandler(Friend parent, string navigationPropertyName)
+ {
+ switch (navigationPropertyName)
+ {
+ case "Orders":
+ return new OrderAPIHandler(parent);
+ default:
+ return null;
+
+ }
+ }
+
+ }
+
+ public class NewOrderAPIHandler : ODataAPIHandler
+ {
+ NewFriend friend;
+ public NewOrderAPIHandler(NewFriend friend)
+ {
+ this.friend = friend;
+ }
+
+ public override ODataAPIResponseStatus TryCreate(IDictionary keyValues, out NewOrder createdObject, out string errorMessage)
+ {
+ createdObject = null;
+ errorMessage = string.Empty;
+
+ try
+ {
+ createdObject = new NewOrder();
+
+ if (friend.NewOrders == null)
+ {
+ friend.NewOrders = new List();
+ }
+
+ friend.NewOrders.Add(createdObject);
+
+ return ODataAPIResponseStatus.Success;
+ }
+ catch (Exception ex)
+ {
+ errorMessage = ex.Message;
+
+ return ODataAPIResponseStatus.Failure;
+ }
+ }
+
+ public override ODataAPIResponseStatus TryDelete(IDictionary keyValues, out string errorMessage)
+ {
+ errorMessage = string.Empty;
+
+ try
+ {
+ var id = keyValues.First().Value.ToString();
+ var friend = this.friend.NewOrders.FirstOrDefault(x => x.Id == int.Parse(id));
+
+ this.friend.NewOrders.Remove(friend);
+
+ return ODataAPIResponseStatus.Success;
+ }
+ catch (Exception ex)
+ {
+ errorMessage = ex.Message;
+
+ return ODataAPIResponseStatus.Failure;
+ }
+ }
+
+ public override ODataAPIResponseStatus TryGet(IDictionary keyValues, out NewOrder originalObject, out string errorMessage)
+ {
+ ODataAPIResponseStatus status = ODataAPIResponseStatus.Success;
+ errorMessage = string.Empty;
+ originalObject = null;
+
+ try
+ {
+ if (friend.NewOrders != null)
+ {
+ var id = keyValues["Id"].ToString();
+ originalObject = friend.NewOrders.FirstOrDefault(x => x.Id == Int32.Parse(id));
+ }
+
+ if (originalObject == null)
+ {
+ status = ODataAPIResponseStatus.NotFound;
+ }
+
+ }
+ catch (Exception ex)
+ {
+ status = ODataAPIResponseStatus.Failure;
+ errorMessage = ex.Message;
+ }
+
+ return status;
+ }
+
+ public override IODataAPIHandler GetNestedHandler(NewOrder parent, string navigationPropertyName)
+ {
+ throw new NotImplementedException();
+ }
+
+ }
+
+ public class MyNewOrderAPIHandler : ODataAPIHandler
+ {
+ MyNewFriend friend;
+ public MyNewOrderAPIHandler(MyNewFriend friend)
+ {
+ this.friend = friend;
+ }
+
+ public override ODataAPIResponseStatus TryCreate(IDictionary keyValues, out MyNewOrder createdObject, out string errorMessage)
+ {
+ createdObject = null;
+ errorMessage = string.Empty;
+
+ try
+ {
+ createdObject = new MyNewOrder();
+
+ if (friend.MyNewOrders == null)
+ {
+ friend.MyNewOrders = new List();
+ }
+
+ friend.MyNewOrders.Add(createdObject);
+
+ return ODataAPIResponseStatus.Success;
+ }
+ catch (Exception ex)
+ {
+ errorMessage = ex.Message;
+
+ return ODataAPIResponseStatus.Failure;
+ }
+ }
+
+ public override ODataAPIResponseStatus TryDelete(IDictionary keyValues, out string errorMessage)
+ {
+ errorMessage = string.Empty;
+
+ try
+ {
+ var id = keyValues.First().Value.ToString();
+ var friend = this.friend.MyNewOrders.FirstOrDefault(x => x.Id == int.Parse(id));
+
+ this.friend.MyNewOrders.Remove(friend);
+
+ return ODataAPIResponseStatus.Success;
+ }
+ catch (Exception ex)
+ {
+ errorMessage = ex.Message;
+
+ return ODataAPIResponseStatus.Failure;
+ }
+ }
+
+ public override ODataAPIResponseStatus TryGet(IDictionary