0
真的很奇怪的問題,我無法解決。Linq加入變量範圍問題
我試圖連接兩個表的LINQ語句只檢索記錄,其中在表1中的記錄在表格中沒有相關行我已經使用2
之前加入,但由於某種原因,我不能讓VS識別linq語句中的第二個表。
EG。
var result =
(from pc in _dataSource.Payments
join bc in _dataSource.BouncedCheques
on pc.PaymentID != bc.PaymentID //This is where the error occurs, VS does not recognise "bc"
where pc.CustomerNumber == getAccountNumber
& pc.IsDeleted == false
orderby pc.PaymentDate descending
select new PaymentAllocation
{
PaymentId = pc.PaymentID,
PaymentDate = pc.PaymentDate,
CustomerNumber = pc.CustomerNumber,
ChequeReference = pc.ChequeReference,
PaymentValue = pc.PaymentValue,
AllocatedValue = pc.AllocatedValue,
UnallocatedValue = pc.PaymentValue - pc.AllocatedValue,
ReceivedBy = pc.ReceivedBy,
PaymentType = pc.PaymentType,
PostedDate = pc.PostedDate
});
基本問題是變量「BC」似乎並不被認可,但是我有幾個其他類似的LINQ查詢,所有的工作做好
任何想法?
這是否意味着除非我正在做一個標準的等於(或覆蓋等於),我必須這樣做嗎?這似乎是進行不同連接的非常低效的方式。 –
我認爲這個想法是,你不使用equals運算符的連接沒有什麼比具有過濾器的笛卡爾產品更能提供性能。 –