Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 60ea5de

Browse filesBrowse files
committed
Fix compiler and update Odata sample
1 parent 3fc0719 commit 60ea5de
Copy full SHA for 60ea5de

File tree

Expand file treeCollapse file tree

8 files changed

+42
-12
lines changed
Filter options
Expand file treeCollapse file tree

8 files changed

+42
-12
lines changed

‎examples/AspNetCore/OData/ODataBasicExample/Controllers/PeopleController.cs

Copy file name to clipboardExpand all lines: examples/AspNetCore/OData/ODataBasicExample/Controllers/PeopleController.cs
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ public IActionResult Get( ODataQueryOptions<Person> options ) =>
2424
Email = "bill.mei@somewhere.com",
2525
Phone = "555-555-5555",
2626
},
27+
new() {
28+
Id = 2,
29+
FirstName = "Xavier",
30+
LastName = "John",
31+
Email = "xavier@heaven.com",
32+
Phone = "666-666-6666",
33+
}
2734
} );
2835

2936
// GET ~/api/people/{key}?api-version=[1.0|2.0]

‎examples/AspNetCore/OData/ODataBasicExample/Program.cs

Copy file name to clipboardExpand all lines: examples/AspNetCore/OData/ODataBasicExample/Program.cs
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
// Add services to the container.
66

7-
builder.Services.AddControllers().AddOData();
7+
builder.Services.AddControllers()
8+
.AddOData( options => options.Select().Filter().OrderBy().SetMaxTop( null ).Count() );
89
builder.Services.AddProblemDetails();
910
builder.Services.AddApiVersioning()
1011
.AddOData(
+22Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
@HostAddress = https://localhost:5001
2+
3+
// Get all records
4+
GET {{HostAddress}}/api/People?api-version=1.0
5+
Accept: application/json
6+
###
7+
8+
// Get all records
9+
GET {{HostAddress}}/api/People?api-version=1.0&$top=1
10+
Accept: application/json
11+
###
12+
13+
// Select firstName
14+
GET {{HostAddress}}/api/People?api-version=1.0&$select=firstName
15+
Accept: application/json
16+
###
17+
18+
19+
// By Key
20+
GET {{HostAddress}}/api/People/5?api-version=1.0
21+
Accept: application/json
22+
###

‎src/AspNet/OData/src/Asp.Versioning.WebApi.OData.ApiExplorer/Conventions/ODataAttributeVisitor.cs

Copy file name to clipboardExpand all lines: src/AspNet/OData/src/Asp.Versioning.WebApi.OData.ApiExplorer/Conventions/ODataAttributeVisitor.cs
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ private void VisitAction( HttpActionDescriptor action )
1313
var attributes = new List<EnableQueryAttribute>( controller.GetCustomAttributes<EnableQueryAttribute>( inherit: true ) );
1414

1515
attributes.AddRange( action.GetCustomAttributes<EnableQueryAttribute>( inherit: true ) );
16-
VisitEnableQuery( attributes );
16+
VisitEnableQuery( attributes.ToArray() );
1717
}
1818
}

‎src/AspNetCore/OData/src/Asp.Versioning.OData/OData/ODataApplicationModelProvider.cs

Copy file name to clipboardExpand all lines: src/AspNetCore/OData/src/Asp.Versioning.OData/OData/ODataApplicationModelProvider.cs
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ private static
141141
return (metadataControllers, supported, deprecated);
142142
}
143143

144-
private static ControllerModel? SelectBestMetadataController( IReadOnlyList<ControllerModel> controllers )
144+
private static ControllerModel? SelectBestMetadataController( ControllerModel[] controllers )
145145
{
146146
// note: there should be at least 2 metadata controllers, but there could be 3+
147147
// if a developer defines their own custom controller. ultimately, there can be
@@ -154,7 +154,7 @@ private static
154154
var original = typeof( MetadataController ).GetTypeInfo();
155155
var versioned = typeof( VersionedMetadataController ).GetTypeInfo();
156156

157-
for ( var i = 0; i < controllers.Count; i++ )
157+
for ( var i = 0; i < controllers.Length; i++ )
158158
{
159159
var controller = controllers[i];
160160

@@ -192,7 +192,7 @@ private void ApplyMetadataControllerConventions(
192192
return;
193193
}
194194

195-
var metadataController = SelectBestMetadataController( metadataControllers );
195+
var metadataController = SelectBestMetadataController( metadataControllers.ToArray() );
196196

197197
if ( metadataController == null )
198198
{

‎src/AspNetCore/OData/test/Asp.Versioning.OData.ApiExplorer.Tests/ApiExplorer/ODataApiDescriptionProviderTest.cs

Copy file name to clipboardExpand all lines: src/AspNetCore/OData/test/Asp.Versioning.OData.ApiExplorer.Tests/ApiExplorer/ODataApiDescriptionProviderTest.cs
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,9 @@ private static void AssertQueryOptionWithoutOData( ApiDescription description, s
256256
parameter.ModelMetadata.Description.Should().EndWith( suffix + '.' );
257257
}
258258

259-
private void PrintGroup( IReadOnlyList<ApiDescription> items )
259+
private void PrintGroup( ApiDescription[] items )
260260
{
261-
for ( var i = 0; i < items.Count; i++ )
261+
for ( var i = 0; i < items.Length; i++ )
262262
{
263263
var item = items[i];
264264
console.WriteLine( $"[{item.GroupName}] {item.HttpMethod} {item.RelativePath}" );

‎src/AspNetCore/WebApi/src/Asp.Versioning.Mvc/ApplicationModels/DefaultApiControllerFilter.cs

Copy file name to clipboardExpand all lines: src/AspNetCore/WebApi/src/Asp.Versioning.Mvc/ApplicationModels/DefaultApiControllerFilter.cs
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace Asp.Versioning.ApplicationModels;
1010
[CLSCompliant( false )]
1111
public sealed class DefaultApiControllerFilter : IApiControllerFilter
1212
{
13-
private readonly IReadOnlyList<IApiControllerSpecification> specifications;
13+
private readonly IApiControllerSpecification[] specifications;
1414

1515
/// <summary>
1616
/// Initializes a new instance of the <see cref="DefaultApiControllerFilter"/> class.
@@ -24,7 +24,7 @@ public DefaultApiControllerFilter( IEnumerable<IApiControllerSpecification> spec
2424
/// <inheritdoc />
2525
public IList<ControllerModel> Apply( IList<ControllerModel> controllers )
2626
{
27-
if ( specifications.Count == 0 )
27+
if ( specifications.Length == 0 )
2828
{
2929
return controllers;
3030
}
@@ -44,7 +44,7 @@ public IList<ControllerModel> Apply( IList<ControllerModel> controllers )
4444

4545
private bool IsApiController( ControllerModel controller )
4646
{
47-
for ( var i = 0; i < specifications.Count; i++ )
47+
for ( var i = 0; i < specifications.Length; i++ )
4848
{
4949
if ( specifications[i].IsSatisfiedBy( controller ) )
5050
{

‎src/Common/src/Common.OData.ApiExplorer/Conventions/ODataAttributeVisitor.cs

Copy file name to clipboardExpand all lines: src/Common/src/Common.OData.ApiExplorer/Conventions/ODataAttributeVisitor.cs
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ private void VisitModel( IEdmStructuredType modelType )
7676
VisitMaxTop( querySettings );
7777
}
7878

79-
private void VisitEnableQuery( IReadOnlyList<EnableQueryAttribute> attributes )
79+
private void VisitEnableQuery(EnableQueryAttribute[] attributes )
8080
{
8181
var @default = new EnableQueryAttribute();
8282

83-
for ( var i = 0; i < attributes.Count; i++ )
83+
for ( var i = 0; i < attributes.Length; i++ )
8484
{
8585
var attribute = attributes[i];
8686

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.