is there a way in C# to store several different view model objects in a var array?
example:
var user_model = db.Database.SqlQuery<User>("SELECT * FROM [User]").ToList();
var product_model = db.Database.SqlQuery<Product>("SELECT * FROM [Product]").ToList();
var my_models = new[]{ user_model, product_model };
string[] object_titles = { "User" , "Product" };
for( int i=0 ; i<my_models.Length ; i++ ){
if( my_models[i].Count() != 0 )
return View("../"+ object_titles[i] +"/Index", my_models[i]);
}
Unfortunately the example above does not work and I do not know how to solve that problem. Could anyone give me a hint, how to solve it?