Hello Team,
I notice in my controller that, it is not loading multiple data with the same Id, ei when I select term one for two or three student, the controller only load one data out of the rest.
public ActionResult getAllFeesPayment()
{
var dataList = objBasicShoolDBEntities.tblFeesPayments.Join(objBasicShoolDBEntities.tblExams,
fee => fee.FeesId,
exam => exam.ExamsTermId,
(fee, exam) => new { fee = fee, exam = exam }).Join(objBasicShoolDBEntities.tblRegistrationFees,
exam => exam.fee.RegistrationId,
registration => registration.RegistrationId,
(exam, registration) => new { registration = registration, exam = exam });
var modifiedData = dataList.GroupBy(x => new { x.exam.fee.FeesId, x.exam.fee.PaymentDate }).Select(x => new TermlyFeesPaymentViewModel
{
FeesId = x.Key.FeesId,
PaymentDate = x.FirstOrDefault().exam.fee.PaymentDate,
FirstName = x.FirstOrDefault().exam.fee.FirstName,
LastName = x.FirstOrDefault().exam.fee.LastName,
ExamsTermId = x.FirstOrDefault().exam.fee.ExamsTermId,
ExamTerm = x.FirstOrDefault().exam.fee.tblExam.ExamTerm,
RegistrationId = x.FirstOrDefault().exam.fee.RegistrationId,
ClassName = x.FirstOrDefault().exam.fee.tblRegistrationFee.ClassName,
Fees = x.FirstOrDefault().exam.fee.tblRegistrationFee.Fees,
FeesPaid = x.FirstOrDefault().exam.fee.FeesPaid,
Wallet = x.FirstOrDefault().exam.fee.Wallet
}).ToList();
return Json(modifiedData, JsonRequestBehavior.AllowGet);
}


Emmmanuel FIADUFEPosted May 12, 2024, 5:39 PM
Hello Team,
This format is wroking but my only problem here is if I want to sum up FeesPaid, I get the below error as shown in the shot below
Jignesh KumarPosted May 12, 2024, 7:58 AM
Hello Emmanuel,
Have you been able to check all tables where you have used join have data for the specified condition for your join?
Emmmanuel FIADUFEPosted May 11, 2024, 3:06 PM
Hello Jaimin
This is the error that popup and when I took away the FirstOrDefault(), additional error popup saying PaymentDate is not defined.
Jaimin ShethiyaPosted May 11, 2024, 10:28 AM
Hello,
Try with below code.
Thanks
Emmmanuel FIADUFEPosted May 10, 2024, 6:34 PM
Hello Abhishek Chadha
Please it is still the same, is not working
Abhishek ChadhaPosted May 10, 2024, 6:25 PM
try the below ---
var modifiedData = dataList.Select(x => new TermlyFeesPaymentViewModel
{
FeesId = x.exam.fee.FeesId,
PaymentDate = x.exam.fee.PaymentDate,
FirstName = x.exam.fee.FirstName,
LastName = x.exam.fee.LastName,
ExamsTermId = x.exam.fee.ExamsTermId,
ExamTerm = x.exam.fee.tblExam.ExamTerm,
RegistrationId = x.exam.fee.RegistrationId,
ClassName = x.exam.fee.tblRegistrationFee.ClassName,
Fees = x.exam.fee.tblRegistrationFee.Fees,
FeesPaid = x.exam.fee.FeesPaid,
Wallet = x.exam.fee.Wallet
}).ToList();