我在2012年與LINQ中的DateTime的Year整數比較,以及年= 2013的LINQ返回行。我想知道我做了什麼錯誤。在LINQ中比較日期時間的年份返回不正確的結果
var accountBalance_query = from report in context.AccountBalances
where report.FiscalYear.Year == reportYear &&
report.CompanyCode == companyCode &&
report.AccountNo == accountNo &&
(subLedgerTypeCode == null) ? report.SubLedgerTypeCode == null : report.SubLedgerTypeCode == subLedgerTypeCode &&
(subLedgerName == null) ? report.SubLedgerName == null : report.SubLedgerName == subLedgerName &&
report.AccountCurrencyCode == transactionCurCode
select report;
var reportCnt = accountBalance_query.Count();
if (reportCnt > 1)
{
reason = "Find more than 1 account balance in database that match the following key. " +
" CompanyCode = " + companyCode +
" AccountNo = " + accountNo +
" SubLedgerTypeCode = " + subLedgerTypeCode +
" SubLedgerName " + subLedgerName +
" Year " + reportYear +
" CurrenyCode " + transactionCurCode;
return false;
}
Model.GeneralLedger.AccountBalance accountBalance;
if (reportCnt == 1)
{
accountBalance = accountBalance_query.First();
}
請更多關注在未來的格式 - 這是無助於必須水平在所有的滾動,更別說當每一行的第一個12個或16個字符都是空格。 –
數據庫中的'FiscalYear'類型是什麼?我想知道這是否是一個時區問題...... –
2013-01-01 00:00:00.000 in DB –