0

In the razor view how can i use @model IEnumerable<> and @model <> ? for single page application

tereško
  • 58,060
  • 25
  • 98
  • 150
sathya
  • 11
  • 2

2 Answers2

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
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