Hi
I want to Bind 2 Linq queries & then Bind To Repeater
C#
public List GetSessionToJoin(Int32 StudentID, String EntriesType)
{
List Result = (from t in context.View_SessionDeliveryCalendarDetails_Students
where t.StudentID == StudentID
&& (EntriesType == "Completed" ? t.CurrentStatus != "Due" && t.ParticipationID != 0 : t.CurrentStatus == "Due")
&& (EntriesType == "Today" ? t.SessionDate == DateTime.Now.Date && t.ActiveParticipant == true : 1 == 1)
&& (EntriesType == "Upcoming" ? t.SessionDate > DateTime.Now.Date && t.ActiveParticipant == true : 1 == 1)
orderby t.SessionDate
select t).ToList();
return Result;
}
public List GetFreeTrialSessionToJoin(Int32 StudentID)
{
List Result = (from t in context.View_BookDeliveryDetails
where t.StudentID == StudentID
select t).ToList();
return Result;
}Thanks

Rajkiran SwainRank #165 · 14.4K reputationPosted Jun 15, 2023, 12:21 PM EDT
public List BindDataToRepeater(Int32 studentID, String entriesType) { List sessionData = GetSessionToJoin(studentID, entriesType); List freeTrialData = GetFreeTrialSessionToJoin(studentID); // Combine the results of both queries into a single collection List combinedData = new List(); combinedData.AddRange(sessionData); combinedData.AddRange(freeTrialData); return combinedData; }Tuhin PaulRank #7 · 71.9K reputationPosted Jun 15, 2023, 10:12 PM EDT
The provided code shared by Rajkiran Swain combines the results of two queries (sessionData and freeTrialData) into a single collection (combinedData) and returns it as a list of objects. If you would like to modify this code, could you please provide more specific details about what changes or enhancements you would like to make? This will help me provide a more accurate modification to the code.
Amit MohantyRank #112 · 20K reputationPosted Jun 16, 2023, 1:03 AM EDT
public List GetSessionsToJoin(Int32 studentID, String entriesType) { var sessions = (from t in context.View_SessionDeliveryCalendarDetails_Students where t.StudentID == studentID && (entriesType == "Completed" ? t.CurrentStatus != "Due" && t.ParticipationID != 0 : t.CurrentStatus == "Due") && (entriesType == "Today" ? t.SessionDate == DateTime.Now.Date && t.ActiveParticipant == true : true) && (entriesType == "Upcoming" ? t.SessionDate > DateTime.Now.Date && t.ActiveParticipant == true : true) orderby t.SessionDate select new { SessionID = t.SessionID, SessionDate = t.SessionDate, // Include other required properties }).ToList(); var freeTrialSessions = (from t in context.View_BookDeliveryDetails where t.StudentID == studentID select new { SessionID = t.SessionID, SessionDate = t.SessionDate, // Include other required properties }).ToList(); var combinedList = sessions.Cast().Concat(freeTrialSessions).ToList(); return combinedList; }