I am very new in .NET and I have the following doubt about these expression that I am finding in some views.
I have a view like this:
@model Vidly_v2.ViewModels.NewCustomerViewModel
@{
/**/
ViewBag.Title = "New";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>New Customer</h2>
@using (Html.BeginForm("Save", "Customers"))
{
<div class="form-group">
@Html.LabelFor(m => m.Customer.Name)
@Html.TextBoxFor(m => m.Customer.Name, new { @class = "form-control" })
</div>
<div class="form-group">
@Html.LabelFor(m => m.Customer.Birthdate)
@Html.TextBoxFor(m => m.Customer.Birthdate, "{0:d MMM yyyy}", new { @class = "form-control" })
</div>
<div class="form-group">
@Html.LabelFor(m => m.Customer.MembershipTypeId)
@Html.DropDownListFor(m => m.Customer.MembershipTypeId, new SelectList(Model.MembershipTypes, "Id", "Name"), "Select Membership Type", new { @class = "form-control" })
</div>
<div class="checkbox">
<label>
@Html.CheckBoxFor(m => m.Customer.IsSubscribedToNewsletter) Subscribed to Newsletter?
</label>
</div>
@Html.HiddenFor(m => m.Customer.Id)
<button type="submit" class="btn btn-primary">Save</button>
}
As you can see in this vire I am using this model object:
@model Vidly_v2.ViewModels.NewCustomerViewModel
Into this view I use this model object in this way:
@Html.LabelFor(m => m.Customer.Name)
@Html.TextBoxFor(m => m.Customer.Name, new { @class = "form-control" })
that simply render this HTML code:
<label for="Customer_Name">Name</label>
<input class="form-control" data-val="true" data-val-length="The field Name must be a string with a maximum length of 255." data-val-length-max="255" data-val-required="The Name field is required." id="Customer_Name" name="Customer.Name" value="" type="text">
related to this model object property.
My doubt is: what exactly is and what represents this expression?
m => m.Customer.Name
I think that m means model object (correct me if I am doing wrong assertion) but I can't understand the meaning and the exact use of this expression.