how use a fk multiplie in a table

I have a Table"Course"

CourseID WeekDayID1 WeekdayID2
1 2 4
1 2 NULL

alse a table "tblSiteWeekDay" that contains week day titles and I also have a CourseModel

public class CourseModel{
public int  CoursID { get; set; }
public string WeekDayTitle1 { get; set; }
public string WeekDayTitle2 { get; set; }
}

some courses will be hold in 2 days of a week the other courses only hold in one day of a week.

I select all the courses with below procedure

select 
        CourseID, 
        tsw1.WeekDayTitle as SiteWeekDayTitle1,
        tsw2.WeekDayTitle as SiteWeekDayTitle2
    
    from 
    Course
    inner join tblSiteWeekDay as tsw1 on tblCourseSchedule.SiteWeekDayID1=tsw1.SiteWeekDayID    
    inner join tblSiteWeekDay as tsw2 on tblCourseSchedule.SiteWeekDayID2=tsw2.SiteWeekDayID 

when I try to show courses in my view IT only shows courses that hold in 2 days of week others courses that hold in one day of a week wont be shown and below code is my html view codes

@foreach (var item in Model)
        {
                        <div><span>@item.WeekDayTitle1</span>
                            @if (item.WeekDayTitle2!="")
                            {
                            <span>و @item.WeekDayTitle2 </span> 
                            }
                            else
                            {
                                <span></span>
                            }
}

sorry for my grammer im not english and please help me this id my first real project



Read more here: https://stackoverflow.com/questions/68484527/how-use-a-fk-multiplie-in-a-table

Content Attribution

This content was originally published by abolfazlrsp at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: