Skip to content

Commit ed2a37a

Browse files
Modify use-web-api post
1 parent ef98500 commit ed2a37a

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

_posts/2015-03-13-how-to-use-web-api-odata-to-build-an-odata-v4-service-without-entity-framework.html

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ <h2>In-Memory data source</h2>
7474
return instance;
7575
}
7676
}
77-
public List<Person> People { get; set; }</p>
77+
public List<Person> People { get; set; }
78+
public List<Trip> Trips { get; set; }
7879
private DemoDataSources()
7980
{
8081
this.Reset();
@@ -83,6 +84,7 @@ <h2>In-Memory data source</h2>
8384
public void Reset()
8485
{
8586
this.People = new List<Person>();
87+
this.Trips = new List<Trip>();
8688
}
8789
public void Initialize()
8890
{
@@ -163,6 +165,7 @@ <h2>Add Controllers</h2>
163165
using System.Web.OData;
164166
namespace Demo.Controllers
165167
{
168+
[EnableQuery]
166169
public class TripsController : ODataController
167170
{
168171
public IHttpActionResult Get()
@@ -211,10 +214,10 @@ <h2>Try with it</h2>
211214
<p>Service document</p>
212215
<p><code>http://localhost:[portNumber]/</code></p>
213216
<p>Service metadata</p>
214-
<p><code>http://localhost:21830/$metadata</code></p>
217+
<p><code>http://localhost:[portNumber]/$metadata</code></p>
215218
<p>Get People</p>
216-
<p><code>http://localhost:21830/People</code></p>
219+
<p><code>http://localhost:[portNumber]/People</code></p>
217220
<p>Queries</p>
218-
<p><code>http://localhost:21830/People?$filter=contains(Description,'Lorem')</code></p>
219-
<p><code>http://localhost:21830/People?$select=Name</code></p>
220-
<p><code>http://localhost:21830/People?$expand=Trips</code></p>
221+
<p><code>http://localhost:[portNumber]/People?$filter=contains(Description,'Lorem')</code></p>
222+
<p><code>http://localhost:[portNumber]/People?$select=Name</code></p>
223+
<p><code>http://localhost:[portNumber]/People?$expand=Trips</code></p>

0 commit comments

Comments
 (0)