欢迎访问我的博客 https://javascript.shop

多表的时候怎样在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_Users
where 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.

posted @ 2017-07-14 00:56  孑孓子  阅读(104)  评论(0编辑  收藏  举报
欢迎访问我的博客 https://javascript.shop