exam questions

Exam 70-483 All Questions

View all questions & answers for the 70-483 exam

Exam 70-483 topic 1 question 5 discussion

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

You are developing an application that uses the Microsoft ADO.NET Entity Framework to retrieve order information from a Microsoft SQL Server database. The application includes the following code. (Line numbers are included for reference only.)

The application must meet the following requirements:
✑ Return only orders that have an OrderDate value other than null.
✑ Return only orders that were placed in the year specified in the OrderDate property or in a later year.
You need to ensure that the application meets the requirements.
Which code segment should you insert at line 08?

  • A. Where order.OrderDate.Value != null && order.OrderDate.Value.Year >= year
  • B. Where order.OrderDate.Value == null && order.OrderDate.Value.Year == year
  • C. Where order.OrderDate.HasValue && order.OrderDate.Value.Year == year
  • D. Where order.OrderDate.Value.Year == year
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️
✑ For the requirement to use an OrderDate value other than null use:

OrderDate.Value != null -
✑ For the requirement to use an OrderDate value for this year or a later year use:
OrderDate.Value>= year

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
apostolin
Highly Voted 5 years, 8 months ago
The correct answer is : Where order.OrderDate.HasValue && order.OrderDate.Value.Year >= year
upvoted 19 times
Kings2020
5 years, 3 months ago
We dont have this option at all
upvoted 3 times
mameenkhn
4 years, 5 months ago
But in Exam you might get this option.
upvoted 2 times
...
...
Idoudist
5 years, 1 month ago
Where order.OrderDate.HasValue && order.OrderDate.Value.Year >= year and Where order.OrderDate.Value != null && order.OrderDate.Value.Year >= year return same result , since we are given the later option A is the correct answer
upvoted 4 times
Weldryn
5 years ago
Wrong. Trying to access a Nullable<T>.Value while there is no value throws an InvalidOperationException so the right answer is as @apostolin stated
upvoted 7 times
...
...
garbageDisposal
4 years, 3 months ago
Your comment is incorrect. I tested it out. For some reason this site won't let me post the code in the comment, but here's a link to the code. You can drop it in the Program.cs of a console application. https://www.codepile.net/pile/035RDQBm
upvoted 2 times
...
...
zzMichielzz
Most Recent 4 years, 6 months ago
A. From the logic B,C,D are equal to the year and it could bet multiple years. (orderdate is nullable btw)
upvoted 2 times
...
cshine
4 years, 7 months ago
Correct Answer (A): Where order.OrderDate.Value != null && order.OrderDate.Value.Year >= year
upvoted 2 times
...
ndlp43
4 years, 9 months ago
A is correct
upvoted 2 times
...
lh2607
4 years, 9 months ago
A is correct
upvoted 2 times
...
XardasLord
4 years, 11 months ago
Answer A
upvoted 4 times
...
robinnirola
5 years ago
Ans: A
upvoted 4 times
...
dominikeps
5 years, 1 month ago
The correct answer is A. Lolsis
upvoted 4 times
...
wealsegun
5 years, 2 months ago
The correct answer is C: Where order.OrderDate.HasValue && order.OrderDate.Value.Year == year
upvoted 2 times
tanujgyan
5 years, 1 month ago
Its not C. you have to include later year also
upvoted 3 times
...
...
Kings2020
5 years, 3 months ago
My Option is to go with "order.OrderDate.Value != null && order.OrderDate.Value.Year >= OrderDate.Value.Year" sinc this option only have > = year as per the requirement "Return only orders that were placed in the year specified in the OrderDate property or in a later year". Please advice me if i miss any.
upvoted 2 times
...
Stnash
5 years, 5 months ago
Its D because int parameter can't be null.
upvoted 2 times
Kings2020
5 years, 3 months ago
Hi, If it is D then records later than a year will not be retrieved. Since D option have condition as "== year"
upvoted 2 times
...
...
banshee
5 years, 6 months ago
Shouldn't it be like this?: order.OrderDate.Value != null && order.OrderDate.Value.Year >= OrderDate.Value.Year Because in the question they're asking for comparing the year from order with the year specified in the OrderDate property, and not the method's parameter.
upvoted 2 times
...
daniel_lobo
5 years, 7 months ago
it is not possible to have order.OrderDate.Value == null
upvoted 4 times
ptarasov
5 years, 3 months ago
Is is possible, because OrderDate is a nullable DateTime.
upvoted 3 times
...
tanujgyan
5 years, 1 month ago
Yes it is possible OrderDate is nullable check it once again
upvoted 2 times
...
Weldryn
5 years ago
It is possible to have order.OrderDate == null but not order.OrderDate.Value == null as it throws an InvalidOperationException
upvoted 4 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 ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago