How to fetch list of model keys from razor file?
Opened this issue · 0 comments
hardik-dhankecha123 commented
I want to fetch list of model keys which are mentioned in the razor file. So how can I fetch the list of keys? My project is based on the forms and fields so based on the keys it will find the fields from the appropriate forms. That's why I need to fetch the keys list from the razor file.
For example: below is a sample razor file.
<acord>
<student>
<firstName>@Model.StudentFirstName</firstName>
<lastName>@Model.StudentLastName</lastName>
@if(@Model.StudentPhone != null)
{
<phone>@Model.StudentPhone</phone>
}
</student>
<parents>
<firstName>@Model.parentFirstName</firstName>
<lastName>@Model.parentLastName</lastName>
</parents>
</acord>
From above sample file I need a list of keys like @Model.StudentFirstName, @Model.StudentLastName, @Model.StudentPhone, @Model.parentFirstName, @Model.parentLastName.
So how can I achieve it? and how can I get a list from the razor file?