In the razor view how can i use @model IEnumerable<> and @model <> ? for single page application
Asked
Active
Viewed 1,574 times
0
-
Check this https://stackoverflow.com/questions/4764011/multiple-models-in-a-view/56705869#56705869 – live-love Jun 21 '19 at 15:03
2 Answers
0
how much i am getting according to your situation you want to pass multiple models on a single view. so for that condition you can use " Tuple "
Example :
Tuple<IEnumerable(ProjectName.FolderName.Classname),ProjectName.FolderName.Class1name>
you can use tuple to pass multiple models on single View.

Soner Gönül
- 97,193
- 102
- 206
- 364

Vaibhav Chaurasiya
- 166
- 9
0
You can bind your view with only a single model. If you want to have multiple models in your view then you should create a model and wrap them into this ViewModel
So for example if you have you models like such -
public class OrdersModel
{
//Properties...
}
public class CustomerPersonalInfoModel
{
//Properties...
}
...and you need to bind them with your view, create a view model for them -
public class CustomerViewModel
{
public System.Collections.Generic.List<OrdersModel> Orders { get; set; }
public CustomerPersonalInfoModel PersonalInfo { get; set; }
}
then you can bind your view with CustomerViewModel
.

Yogi
- 9,174
- 2
- 46
- 61