Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8367821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:15:10+00:00 2026-06-09T13:15:10+00:00

a few newbie questions here: In a strongly typed view, why: @model MyProj.Models.User Why

  • 0

a few newbie questions here:

In a strongly typed view, why:

@model MyProj.Models.User

Why do we use lambdas: ? What exactly does that do? Why not just model.Email?

1. @Html.DisplayNameFor(model => model.Email)

Why doesn’t this work? Didn’t we call the variable model? (I know I should use @html.() but why isn’t model recognisable?

2. users name is: @model.Name 

Why does it work with an uppercase ‘M’? Didnt we name it with a lower case?

3. users name is: Model.Name

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T13:15:11+00:00Added an answer on June 9, 2026 at 1:15 pm

    Why do we use lambdas: ? What exactly does that do? Why not just
    model.Email?

    The DisplayNameFor as well as all the other *For helper methods are taking advantage of the ability of lambda expressions to participate in Expression Trees.

    By itself this lambda expression is simply taking in a model type and returning a String. But there is more information needed to get the display name.

    In pseudo code, that method is doing:

    1.) Treat the lambda as an Expression
    2.) Parse the expression to get the name of the property
    3.) Use reflection to get the DisplayNameAttribute for that property
    4.) Extract the value if it exists, otherwise use the name of the property
    5.) Generate a label for that property using either the display name, or property name

    Without using Expression trees, you would end up having to pass the property name in as a string… and that just sucks. This provides a strongly typed way of using reflection without magic strings.

    Why doesn’t this work? Didn’t we call the variable model? (I know I
    should use @html.() but why isn’t model recognisable?

    @model is a special directive that is treated differently by Razor. It’s like a reserved keyword that isn’t any different than class or int.

    Why does it work with an uppercase ‘M’? Didnt we name it with a lower
    case?

    Model is a property on your view that has the type you defined using the @model directive, and references your model. Without using the @model directive it would have a type of dynamic.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a newbie user of Frama-C and have a few questions regarding assertions
Newbie-ish questions ahead: Where should I put my View Model declarations? I created a
As a newbie of Zend framework, I have a few version-dependent questions on the
I am a newbie in network related aspects. I have few basic questions related
I'm learning F# from just a few days, so here's a newbie question: I've
I'm learning vba today, I'm a newbie and I have a few questions about
Im a newbie PHP programmer and I have a few questions about creating a
I'm a newbie to the xCode world and I had a few questions regarding
I have a few newbie web service/Windows rights questions since I've typically been a
Newbie to web-services, so asking few basic questions I have a some data around

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.