How do I create a view with information from multiple tables?
Select product.prodname, club.clubname from product left join club on product.clubid = club.clubid where club = "Miami Heat"
Newbie to MVC
we use ViewModel
for that purpose in mvc
where we create model according to view
eg i have a view which needs ProducName
and ClubName
but they both are from different model, so i will create a view model
public class PageViewModel
public string ProducName { get; set; }
public string ClubName { get; set; }
so in view i will use PageViewModel
as model
and in query
var data = from p in product
join c in club on p.clubid = c.clubid
where c = "Miami Heat"
select new PageViewModel
{
ProducName= p.prodname,
ClubName= c.clubname
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.