-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EnableQuery should perform checks before controller execution (#51)
* Porting change to v8 * Adding commit signing from VS * Removing commit * Removing the config file since it is not working * Trying with GitConfig * Removing gitconfig * Removing unnecessary usings * Fixing usings * Update ODataOptionsTests.cs Co-authored-by: Sam Xu <saxu@microsoft.com>
- Loading branch information
1 parent
76c833e
commit 97f6b8b
Showing
9 changed files
with
356 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
test/Microsoft.AspNetCore.OData.E2E.Tests/Query/ActionResult/ActionResultController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.OData.Query; | ||
|
||
namespace Microsoft.AspNetCore.OData.E2E.Tests.Query.ActionResult | ||
{ | ||
public class CustomersController : ControllerBase | ||
{ | ||
[HttpGet] | ||
[EnableQuery(AllowedQueryOptions = AllowedQueryOptions.Expand)] | ||
public async Task<ActionResult<IEnumerable<Customer>>> Get() | ||
{ | ||
return await Task.FromResult(new List<Customer> | ||
{ | ||
new Customer | ||
{ | ||
Id = "CustId", | ||
Books = new List<Book> | ||
{ | ||
new Book | ||
{ | ||
Id = "BookId", | ||
}, | ||
}, | ||
}, | ||
}); | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
test/Microsoft.AspNetCore.OData.E2E.Tests/Query/ActionResult/ActionResultEdmModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
|
||
using Microsoft.OData.Edm; | ||
using Microsoft.OData.ModelBuilder; | ||
|
||
namespace Microsoft.AspNetCore.OData.E2E.Tests.Query.ActionResult | ||
{ | ||
public class ActionResultEdmModel | ||
{ | ||
public static IEdmModel GetEdmModel() | ||
{ | ||
var builder = new ODataConventionModelBuilder(); | ||
builder.EntitySet<Customer>("Customers"); | ||
return builder.GetEdmModel(); | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
test/Microsoft.AspNetCore.OData.E2E.Tests/Query/ActionResult/ActionResultODataModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// 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.AspNetCore.OData.E2E.Tests.Query.ActionResult | ||
{ | ||
public class Customer | ||
{ | ||
public string Id { get; set; } | ||
|
||
public IEnumerable<Book> Books { get; set; } | ||
} | ||
|
||
public class Book | ||
{ | ||
public string Id { get; set; } | ||
} | ||
} |
Oops, something went wrong.