我有兩個表,分別是客戶和付款。
Table Customers ==> Columns [CustomerId, ...other customer info].
表Payments ==> 列[PaymentId, CustomerId, Year, ...其他付款資訊]。
我怎樣才能得到今年還沒有付款的客戶。我不知道我需要什么。
import System.Linq;
var result = from customers in context.Customers
join payments from context.Payments
on customers.CustomerId equals payments.CustomerId
where payments.Year == 2021 into paymentsCount
where paymentsCount.count == 0;
uj5u.com熱心網友回復:
如果你有適當的導航屬性:
var query = context.Customers
.Where(c => !c.Payments.Any(p => p.Year == 2021) )。
如果沒有合適的導航屬性:
var query = context.Customers
.Where(c => !context.Payments.Any(p => p.CustomerId == c.CustomerId && p.Year == 2021) 。)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/310106.html
標籤:
上一篇:ChoETL嵌套JSON到CSV
