多表的时候怎样在MVC VIEW中显示
原文发布时间为:2011-04-01 —— 来源于本人的百度文章 [由搬家工具导入]
Linq join query displayed in MVC view
Instead of returning an IEnumerable of anonymous types, you could create a class for the join result and then create a model for it as normal:
var inactive = from usrs in ctn.aspnet_Userswhere usrs.LastActivityDate <= duration
join o in ctn.Groups on
usrs.UserId equals o.UserID
select new InactiveUser(usrs.UserName, usrs.LastActivityDate, o.PrimaryPhoneNumber);
With an InactiveUser class which has a constructor which takes a UserName, Date and PhoneNumber.