我的Table1包含以下列。

我的Table2包含

我目前正在從 Table1 中獲取日期范圍內的所有行,如下所示:
dbRowList = context.Table1.Where(x => x.dateTime > from && x.dateTime < to).ToList();
但是,我還想只獲取idCycleTable2 中相同的行(= Table1 的 id)具有具有特定字串內容的“標簽”欄位。
如何加入它或使用 LINQ 查詢它?
uj5u.com熱心網友回復:
Table1.idTable1 在=上加入 Table2Table2.idCycle。- 篩選表 1 中的記錄和表 2 中的標簽的日期范圍。
- 從 Table1 中選擇所有列(或指定所需的列)。
var result = (from a in context.Table1
join b in context.Table2 on a.id equals b.idCycle
where (a.dateTime > from && a.dateTime < to)
and b.label = /* Value for Label to filter */
select a
)
.ToList();
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/460844.html
