-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update getting-started.md #296
base: main
Are you sure you want to change the base?
Conversation
Adapt get method by key
Learn Build status updates of commit d8c75bd: ✅ Validation status: passed
For more details, please refer to the build report. For any questions, please:
|
Learn Build status updates of commit 4933754: ✅ Validation status: passed
For more details, please refer to the build report. For any questions, please:
|
Learn Build status updates of commit 3602f07: ✅ Validation status: passed
For more details, please refer to the build report. For any questions, please:
|
@microsoft-github-policy-service agree |
Learn Build status updates of commit e9d9d88: ✅ Validation status: passed
For more details, please refer to the build report. For any questions, please:
|
@@ -148,16 +148,10 @@ namespace Lab01.Controllers | |||
} | |||
|
|||
[EnableQuery] | |||
public ActionResult<Customer> Get([FromRoute] int key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no reason for this change. $expand
works okay even when the return type is ActionResult<Customer>
.
@@ -376,20 +376,14 @@ The following JSON payload shows the expected response: | |||
## Request a single entity | |||
To support this request, we add a controller action named `Get` (or `GetCustomer`) to the `CustomersController` class. The action should accept a single parameter named `key` of type `int` - same type as the entity's key property: | |||
```csharp | |||
public ActionResult<Customer> Get([FromRoute] int key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no reason for this change. $expand
works okay even when the return type is ActionResult<Customer>
.
|
||
return Ok(customer); | ||
var item = customers.AsQueryable().Where(c => c.Id == id); | ||
return SingleResult.Create(item); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no reason for this change. $expand
works okay even when the return type is ActionResult
.
@michelcedric There's no reason for the changes that you proposed. Query options work okay even when the return type is |
@gathogojr |
@michelcedric The sample code in this tutorial uses an in-memory collection as a data store. In my opinion, it'd be more ideal to have a different article with code samples that are relevant to an SQL Server data store where we can employ the use of |
Adapt get method by key
An odata endpoint must return a IQueryable.
If you evaluate it directly in the return of the controller method, the odata query feature (example : expand) can't working.
If you directly return the queryable you return an array with only one element.
You can fix that with the usage of
SingleResult.Create method form odata