 分类:
    Mvc EF框架
    
    分类:
    Mvc EF框架
后台控制器封装代码:
//用户分数显示2
        public ActionResult UserScoreDel()
        {
            //创建数据源
            oaEntities1 oae = new oaEntities1();
            var result = oae.Users.GroupJoin(oae.User_Score, a => a.Id, b => b.UserId, (u, p) => new 
            {
                //a:代表第一张表,b:代表第二章表
                UserName = u.UserName,
                scoreList = p
                //总结:DefaultIfEmpty():就是集合里没有默认为空
                //a:代表SelectMany()方法以前的内容,b:代表UserScoreViewModel3里的scoreList集合
                //就是最后一次a承接了上一次所有的内容
            }).SelectMany(a=>a.scoreList.DefaultIfEmpty(),(a,b)=>new UserScoreViewModel3
            {
            UserName=a.UserName,
            Sub=b.Sub,
            Score=b.Score
            }).ToList();
            return View(result);
        }以上是个人总结:希望对读者有帮助
评价
    
                    排名
                
                
                    6
                
            
                    文章
                
                
                    6
                
            
                    粉丝
                
                
                    16
                
            
                    评论
                
                
                    8
                
            
            {{item.articleTitle}}
            
    {{item.blogName}} : {{item.content}}
        
            ICP备案  :渝ICP备18016597号-1
        
        
            网站信息:2018-2025TNBLOG.NET
        
        
            技术交流:群号656732739
        
        
            联系我们:contact@tnblog.net
        
        
            公网安备: 50010702506256
50010702506256
        
     50010702506256
50010702506256
         
        
            欢迎加群交流技术
        
     
         
         
        