Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to Run Linq Query in .Net to Get Subjectwise Average Score of a Student of Current Month

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 593
    Answer it

    How to Run Linq Query in .Net to Get Subjectwise Average Score of a Student of Current Month.
     

     

            public GetCalculatePerform(int? Student_ID, int? CourseID, int? SemID)
            {
    
                var newlist1 = dbcontext.Stu_Result
                               .Where(u => u.CourseID == CourseID && u.SemID == SemID)
                               .ToList();
                var scoreCard = (from i in newlist1
                                 group i by new { i.SubjectID, i.CourseID } into j
                                 select new UserRankObject
                                 {
                                     SubjectID = j.Key.SubjectID,
                                     //UnitID = j.Key.UnitID,
                                     //CourseID = j.Key.CourseID,
                                     //MarksScored = j.GroupBy(a => a.UnitID).SelectMany(g => g.OrderByDescending(d => d.).Take(1)).FirstOrDefault()
                                     AverageScore = j.Average(u => u.ScoredMarks)
                                 }).ToList().FirstOrDefault();
    }
    
    
    
                this.tempobj = scoreCard;

     

     

    RID	UserID	CourseID	SemID	SubjectID	UnitID	ScoredMarks	TotalMarks	No_Attempts	CreatedDate	
    2	1004	109	        124	      2006	        100	    50	    100	         1      	 2019-04-11  
    3	1004	109	        124       2006	        100	    60	    100	         1	         2019-04-11 
    8	1004	109	        124	      2006	        101	    70	    100	         1	         2019-04-11 
    9	1004	109	        124       2006	        103	    40	    100	         1	         2019-02-22
    58	1004	109	        124	      2006	        100	    80	    100	         1	         2019-03-30 
    59	1004	109	        124       2007	        100	    90	    100	         1	         2019-04-05 
    60	1004	109	        124	      2007	        101	    60	    100	         1	         2019-04-05  
    79	1004	109	        124	      2007	        101	    74	    100	         1	         2019-04-06 
    80	1004	109	        124	      2007	        100	    48	    100	         1	         2019-04-11  
    81	1004	109	        124	      2007	        101	    68	    100	         1	         2019-04-11   

     

    Explanation:

    2006: on 11/04/2019 average is (60+70)=65    note : 50 is discarded if same unit id found select max value.

    2007: : 05/04/2019 average is (90+60)=75 

    2007: 06/04/2019 average is (74)

    2007: 11/04/2019 average is (48+68)=58

    remaining data is not belongs to April(Current) month so discard that 

     

    Expected Output:

    subjectid:2007 average: 75 date : 05/04/2019

    subjectid: 2007 average: 74 date : 06/04/2019

    subjectid: 2006 average: 65 date : 11/04/2019

    subjectid: 2007 average: 58 date : 11/04/2019

     

 0 Answer(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: