我想獲得所有與 Pre_Number=null 相關(guān)的所有 Reconcile_Status 的 Pre_Number。在這種情況下,列表中不應(yīng)該有任何項(xiàng)目。如果會(huì)有一些其他的 Pre_number 例如。7/2018 并且它有兩條記錄,并且這些記錄的 Reconcile_Status 為 NULL,那么我應(yīng)該在列表中獲得一項(xiàng) 7/2018。我試過(guò)var NoNReconciled = context.tbl_prerelease_invoice .Where(x => x.Reconcile_Status==null) .Select(y => new { y.Pre_number }).Distinct().ToList();但我得到了 6/2018
3 回答

弒天下
TA貢獻(xiàn)1818條經(jīng)驗(yàn) 獲得超8個(gè)贊
無(wú)需為 Pre_Number 創(chuàng)建匿名對(duì)象。試試下面的代碼
var NoNReconciled = context.tbl_prerelease_invoice
.Where(x => x.Reconcile_Status==null)
.Select(y => y.Pre_number).Distinct().ToList();

料青山看我應(yīng)如是
TA貢獻(xiàn)1772條經(jīng)驗(yàn) 獲得超8個(gè)贊
嘗試這個(gè)-
context.tbl_prerelease_invoice.GroupBy(r => r.Pre_number).Where(kv => kv.All(r => r.Reconcile_Status==null)).Select(kv => kv.Key).ToList();
- 3 回答
- 0 關(guān)注
- 203 瀏覽
添加回答
舉報(bào)
0/150
提交
取消