我有以下LINQ查询(为简洁而编辑),当TerminationReason
既不是Any
也不是NotTerminated
时,应评估TerminationDateRange
,但这总是返回true
长时间盯着这个,会欣赏另一双眼睛。已确认数据可返回预期值。
var contracts = from x in yyy
where aaa == bbb
&& …other logic…
) && (
TerminationReason.Any == _TerminationReason ? true
: TerminationReason.NotTerminated == _TerminationReason ? t.TerminationID == null
: (
TerminationDateRange.Any == _TerminationDateRange ? true
: TerminationDateRange.PriorDayToPED == _TerminationDateRange ? t.TerminationDate.Day < PeriodEndDate.Day
: TerminationDateRange.SameDayAsPED == _TerminationDateRange ? t.TerminationDate.Day == PeriodEndDate.Day
: true
&&
TerminationReason.ForCause == _TerminationReason ? t.Reason == FOR_CAUSE
: TerminationReason.WithoutCause == _TerminationReason ? t.Reason == WITHOUT_CAUSE
: TerminationReason.Voluntary == _TerminationReason ? t.Reason == VOLUNTARY
: true
)
)
select new ContractInfo
{
...
};