exam questions

Exam 70-487 All Questions

View all questions & answers for the 70-487 exam

Exam 70-487 topic 7 question 1 discussion

Actual exam question from Microsoft's 70-487
Question #: 1
Topic #: 7
[All 70-487 Questions]

You are developing an ASP.NET MVC application. The application has a page that updates an image stored in a database. Members of the EntityClient namespace are used to access an Entity Framework data model. Images and associated metadata are stored in a single database table.
You need to run a single query that updates an image and associated metadata in the database while returning only the number of affected rows.
Which method of the EntityCommand type should you use?

  • A. ExecuteScalar()
  • B. ExecuteDbDataReader()
  • C. ExecuteReader()
  • D. ExecuteNonQuery()
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️
EntityCommand.ExecuteNonQuery method executes the current command, and returns the number of rows affected.
Incorrect Answers:
A: ExecuteScalar() executes the command, and returns the first column of the first row in the result set. Additional columns or rows are ignored.
References:
https://docs.microsoft.com/en-us/dotnet/api/system.data.entityclient.entitycommand.executenonquery https://docs.microsoft.com/en-us/dotnet/api/system.data.entityclient.entitycommand.executescalar

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
pizzaHawai
4 years, 5 months ago
Answer (D) is correct. See also: https://stackoverflow.com/a/21059581/4884274
upvoted 2 times
...
bashirmja
4 years, 5 months ago
Should be A. "Executes the query, and returns the first column of the first row in the result set returned by the query. Additional columns or rows are ignored." Source: https://docs.microsoft.com/en-us/dotnet/api/system.data.sqlclient.sqlcommand.executescalar?view=dotnet-plat-ext-5.0
upvoted 2 times
bashirmja
4 years, 5 months ago
I did not notice the requirement: "returning only the number of affected rows". Which the right answer is option D.
upvoted 1 times
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...