如何在MVC中查看列表对象?
如何在MVC中查看列表对象?
在控制器页面上:\n
object likes = (from p in ctx.Profiles join sl in ctx.SuggestionLikes on p.UserId equals sl.UserId join s in ctx.Suggestions on sl.SuggestionId equals s.Id join u in ctx.Users on s.Crtr equals u.Id where u.Email == mail orderby sl.LikeDate descending select new LikeClass { UserName = p.UserName, UserId = p.UserId, PhotoUrl = p.PhotoUrl, OneriId = s.Id, LikeDate = sl.LikeDate }).Take(10).ToList(); object comments = (from p in ctx.Profiles join sc in ctx.SuggestionComments on p.UserId equals sc.Crtr join s in ctx.Suggestions on sc.SuggestionId equals s.Id join u in ctx.Users on s.Crtr equals u.Id where u.Email == mail orderby sc.Crtm descending select new CommentClass { UserName = p.UserName, UserId = p.UserId, PhotoUrl = p.PhotoUrl, OneriId = s.Id, Crtm = sc.Crtm }).Take(10).ToList(); object follows = (from u in ctx.Users join f in ctx.Follows on u.Id equals f.FollowerId where f.FollowingId == user_id orderby f.FollowDate descending select new FollowClass { UserName = u.UserName, FollowDate = f.FollowDate, UserId = u.Id, ThumbnailUrl = u.ThumbnailUrl }).Take(10).ToList(); List
\n在视图页面上:\n@model IEnumerable
\n
\n
\n
\n
\n
\n
\n}\n
\n@foreach (var item in list_comment)\n{\n
\n
\n
\n
\n
\n
\n}\n
\n@foreach (var item in list_follow)\n{\n
\n
\n
\n
\n
\n}\n\n我想在视图页面中显示对象项。但它不起作用,返回空值。请帮忙。\n例如:item.UserName是空引用,但在SQL查询中不是空值。