【发布时间】:2015-05-12 22:21:42
【问题描述】:
我在文本框中插入学生的 ID,我想返回不同标签中的所有值。如果正在使用三个表学生,参加和课程。学生的 SID 在参加表中是外键,课程的 cID 在参加表中具有外键。 我正在加入这三个表。
Attend obJ = new Attend();
Student oAd = new Student();
oAd.sID = int.Parse(metroTextBox1.Text);
var entryPoint = (from ep in dbContext.Attends
join en in dbContext.Students on ep.sID equals en.sID join te
in dbContext.Courses on ep.cID equals te.cId
where en.sID == oAd.sID
select new{
Name = en.First_Name,
Course = te.Name,
Presents=ep.Present,
Absents=ep.Absent,
});
foreach (var iL in entryPoint) {
metroLabel1.Text = iL.Name;
metroLabel2.Text = iL.Course;
metroLabel3.Text = iL.Absents.ToString();
metroLabel4.Text = iL.Presents.ToString();
}
代码没有给出任何我想显示的响应,尽管它没有给出任何错误
Student table Sid is in Attend Table
Course table cID is in Attend Table
通过加入这三个表格,我想显示哪个学生上过哪门课程以及该课程的名称是什么
【问题讨论】:
标签: c# linq entity-framework