diff --git a/examples/AspNetCore/OData/ODataBasicExample/Controllers/PeopleController.cs b/examples/AspNetCore/OData/ODataBasicExample/Controllers/PeopleController.cs index 01d0c61e..ba41dd73 100644 --- a/examples/AspNetCore/OData/ODataBasicExample/Controllers/PeopleController.cs +++ b/examples/AspNetCore/OData/ODataBasicExample/Controllers/PeopleController.cs @@ -24,6 +24,13 @@ public IActionResult Get( ODataQueryOptions options ) => Email = "bill.mei@somewhere.com", Phone = "555-555-5555", }, + new() { + Id = 2, + FirstName = "Xavier", + LastName = "John", + Email = "xavier@heaven.com", + Phone = "666-666-6666", + } } ); // GET ~/api/people/{key}?api-version=[1.0|2.0] diff --git a/examples/AspNetCore/OData/ODataBasicExample/Program.cs b/examples/AspNetCore/OData/ODataBasicExample/Program.cs index a269f238..7a370f68 100644 --- a/examples/AspNetCore/OData/ODataBasicExample/Program.cs +++ b/examples/AspNetCore/OData/ODataBasicExample/Program.cs @@ -4,7 +4,10 @@ // Add services to the container. -builder.Services.AddControllers().AddOData(); +builder.Services + .AddControllers() + .AddOData( options => options.Select().Filter().OrderBy().SetMaxTop( null ).Count() ); + builder.Services.AddProblemDetails(); builder.Services.AddApiVersioning() .AddOData( @@ -15,10 +18,10 @@ // is merely illustrating that they can coexist and allows you // to easily experiment with either configuration. one of these // would be removed in a real application. - + // WHEN VERSIONING BY: query string, header, or media type options.AddRouteComponents( "api" ); - + // WHEN VERSIONING BY: url segment options.AddRouteComponents( "api/v{version:apiVersion}" ); } ); diff --git a/examples/AspNetCore/OData/ODataBasicExample/odatabasicexample.http b/examples/AspNetCore/OData/ODataBasicExample/odatabasicexample.http new file mode 100644 index 00000000..fc4e3d34 --- /dev/null +++ b/examples/AspNetCore/OData/ODataBasicExample/odatabasicexample.http @@ -0,0 +1,22 @@ +@HostAddress = https://localhost:5001 + +// Get all records +GET {{HostAddress}}/api/People?api-version=1.0 +Accept: application/json +### + +// Get all records +GET {{HostAddress}}/api/People?api-version=1.0&$top=1 +Accept: application/json +### + +// Select firstName +GET {{HostAddress}}/api/People?api-version=1.0&$select=firstName +Accept: application/json +### + + +// By Key +GET {{HostAddress}}/api/People/5?api-version=1.0 +Accept: application/json +### \ No newline at end of file