Note that there are some explanatory texts on larger screens.

plurals
  1. POquestion on linq select join
    text
    copied!<p>I would like to list out all the students who have yet to pay off their course fee i.e. when a student is clicked, list out all pending fees by months.</p> <p>This is what I have done so far..<br> These are all the students active courses. <img src="https://i.stack.imgur.com/RHXyG.png" alt=""></p> <p>Below are the payments record paid by student to their course. <img src="https://i.stack.imgur.com/w52ye.jpg" alt="enter image description here"> <br> Now i would like to list out all the pending payment foreach students e.g. last payment to the course is on 2/11/2011. If the datetime now is May, Then i would like to show the pending amount as <br> Month Amount<br> March 100<br> April 200<br> May 400<br></p> <p>This is what I tried..</p> <pre><code>foreach (var result in activeCourses) { //Show all the pending paid coures from dateJoin till datetime.Now DateTime JoinedDate = Convert.ToDateTime(result.cus.Date); for (DateTime d = JoinedDate; d.Month &lt;= DateTime.Now.Month; d = d.AddMonths(1)) { Payment payment = new Payment(); payment.Course.Id = result.c.Id; payment.Course.Name = result.c.Name; payment.Course.Fee = result.c.Fee; payment.CourseByStudent.CourseUserStatus.Date = result.cu.Date; payment.CourseByTutor.TutorId = result.t.TutorId; payment.User.Name = result.u.Name; payment.MonthId = d.Month; payment.MonthToPay = d.ToString("MMM"); output.Add(payment); } } </code></pre> <p><br> The logic given above does not seem to be efficient in case the student does not pay anything for his courses, then I have to check the pending payment since his first JoinedDate. OtherWise I need to check the pending payment from the DateIssue in the Payment table according to that particular course..please advice thanks</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload