我正在使用 C# WPF 和 Entity Framework 6 开发一个小项目
我需要查询表 1 中列 ID 的 ID 等于表 2 中列 ID 的 ID。
谁能帮帮我?
亲切的问候
Cursus cursus = DWE.Cursus.Where(x => x.Naam == CurNaam).First();
TbNaam.Text = CurNaam;
TbOmschrijving.Text = cursus.Omschrijving;
CmbSelBoot.SelectedValue = cursus.BootID;
TbPrijs.Text = cursus.Prijs.ToString();
//the following 2 lines should get the data from the new cursusweek table
BeginDate.SelectedDate = Utils.UnixTimeStampToDateTime(Cursus.Begint);
Enddate.SelectedDate = Utils.UnixTimeStampToDateTime(cursus.Eindigt);
数据库概览:
你可以看到我想从 Cursusweek 获取数据。 我已经从 Cursus 获得了 ID,我想利用该 ID 从 Cursusweek 表中获取正确的数据。
最佳答案
这应该接近您的需要:
var cursusWeek = Cursusweek
.Where(x => x.CursusId = cursus.CursusId)
.Select(x => new { Begint = x.Begint, Eindigt = x.Eindigt })
.ToList();
关于c# - 查询 id 等于其他列的 id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41704274/