LINQ案例逻辑总是返回true,当它不应该时

时间:2012-02-02 11:31:33

标签: c# linq

我有以下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
                {
                    ...
                };

0 个答案:

没有答案