Controller
Public Actionresult index () {viewbag. Message = " Welcome to ASP. net mvc! " ; List <Table01> List = New List <table01> (); List <Table02> list2 = New List <table02> (); Using (Testentities TE = New Testentities () {list = ( From M In Te. table01 Select M). tolist <table01> (); List2 = ( From M In Te. table02 Select M). tolist <table02> ();} Idictionary < String , Object > Test = New Dictionary < String , Object > (); Test. Add ( " T1 " , List); test. Add ( " T2 " , List2 ); Return View (TEST );}
And then in the view
@ Model idictionary < String , Object > @ {Viewbag. Title = "Homepage ";} < H2 > @ Viewbag. Message </ H2 > < P > For more information about ASP. net mvc, visit < A Href = "Http://asp.net/mvc" Title = "ASP. net mvc Website" > Http://asp.net/mvc </ A > . </ P > @ {Foreach (VAR item in (list < Mvcapplication1 . Table01 > ) Model ["T1"]) { < P > < A Href = "@ Item. ID" > @ Item. Name </ A > </ P > }}
Returning multiple objects is the same solution.