exam questions

Exam 70-487 All Questions

View all questions & answers for the 70-487 exam

Exam 70-487 topic 1 question 109 discussion

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

HOTSPOT -
You are maintaining a ASP.NET Core web application that uses Entity Framework Core for data access. The application contains a model class named Student.
You must add a field named FirstName to the class. The field has following requirements:
✑ Use a non-nullable field named FName to store data in a Microsoft SQL Server database.
✑ The data length must be between 2 and 50 characters.
The application user interface must display an error message if the maximum or minimum length requirements are not met.
You need to implement the FirstName field.
How should you complete the code? To answer, select the appropriate code segments to use in the answer area.
Each correct selection is worth one point.
NOTE:
Hot Area:

Show Suggested Answer Hide Answer
Suggested Answer:
References:
https://docs.microsoft.com/en-us/aspnet/core/tutorials/first-mvc-app/validation?view=aspnetcore-2.2

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
bobtables
Highly Voted 5 years, 8 months ago
I think the answer is... [Required] [StringLength(..)] [Column("FName")] https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.dataannotations.schema.columnattribute?view=netframework-4.8
upvoted 75 times
abalone
5 years, 8 months ago
agreed with bobtables
upvoted 3 times
tiger25
5 years, 5 months ago
agreed
upvoted 2 times
chirag6456
5 years, 3 months ago
agreed
upvoted 2 times
...
...
...
mr_
5 years ago
Agree with you.
upvoted 2 times
...
...
mfg41
Highly Voted 5 years, 5 months ago
[Required] [StringLength()] [Column(Name="")] "field named FName to store data in a Microsoft SQL Server database" so 3rd answer should be 'Column'
upvoted 11 times
...
mr_
Most Recent 5 years ago
My answer is definitely: [Required] [StringLength(...)] [Column("FName")]
upvoted 11 times
...
gclopes
5 years, 7 months ago
Range is used for admissible values like Age values(0-100). String Length is to define max and min lenght for a field of type string. In the question it says that the database field should be named FName so, column(Fname) is for this purpose. Please check this: https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.dataannotations?view=netframework-4.8
upvoted 7 times
...
Snowpl
5 years, 7 months ago
[Required] [StringLength(..)] [Display(Name = "FName")]
upvoted 6 times
mr_
5 years ago
Wrong. DisplayAttribute is more for localization purposes. There is strict requirement to map to a DB column named 'FName', not for displaying purposes.
upvoted 3 times
...
...
seanlim
5 years, 8 months ago
I could not delete my old comment. This is final. [Required] [Range(..)] [Column("FName")] https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.dataannotations.rangeattribute?view=netframework-4.8
upvoted 5 times
mr_
5 years ago
Wrong. Not range. It is for numeric data types. 'Specifies the numeric range constraints for the value of a data field.'
upvoted 3 times
...
...
seanlim
5 years, 8 months ago
Sorry, the below is my answer. [Required] [StringLength(..)] [Column("FName")] https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.dataannotations.rangeattribute?view=netframework-4.8
upvoted 7 times
...
seanlim
5 years, 8 months ago
[Min..] [Max..] [Column..] 'Required' allows 1 character, but '2' should be set at any place Column means database column name https://www.c-sharpcorner.com/article/using-net-core-data-annotation/
upvoted 1 times
mfg41
5 years, 5 months ago
when using the 'min' attribute, you should use the 'required' attribute.
upvoted 1 times
...
...
MJKWandile
5 years, 8 months ago
[Required] [Range(..)] [Display(Name ="FName")]
upvoted 2 times
MJKWandile
5 years, 8 months ago
[Required] [StringLength(..)] [Display(Name ="FName")]
upvoted 21 times
ammariii
4 years, 8 months ago
[Display(Name="FName")] , It will be on web UI only, but since say field name in sql server database , so I agree for the third one >> Column("FName")
upvoted 2 times
...
...
LeSpam
4 years, 10 months ago
Required StringLength Column It's not range because that is used for number properties not strings. It needs to be column because that's the database column name. Display is used for view presentation rendering.
upvoted 13 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 ...