There are multiple where clauses chained in this code. I need to change the logic for the last where clause in the below code snippet to behave as an "OR" instead of "AND". The logic behind this is that I want all transactions that fall between the passed in date range AND all transactions that have a status of TransactionStatus.Outstanding. Currently the logic is doing an AND so it is only giving me the intersect between the two.
I have seen many other posts in Stack overflow addressing the scenario I am dealing with, but none seem to help me.
Any guidance with the code syntax would be greatly appreciated!
IQueryable<Transaction> transactions =
_db.Transactions
.Include(t => t.DepositSource)
.Include(t => t.WithdrawalSource)
.Include(t => t.ReconciliationReport)
.Where(t => t.FundId == fundId);
if (criteria.UseClearedDate)
{
transactions = transactions
.Where(t => t.ReconciliationReport != null
&& (t.ReconciliationReport.DateCreated.Date >= criteria.StartDate.Date
&& t.ReconciliationReport.DateCreated.Date <= criteria.EndDate.Date));
}
else
{
transactions = transactions
.Where(t => t.Date.Date >= criteria.StartDate.Date
&& t.Date.Date <= criteria.EndDate.Date);
}
transactions = transactions
.Where(t => (criteria.Statuses.Contains(t.ReconciliationId == null
? t.IsVoided
? TransactionStatus.Void
: TransactionStatus.Outstanding
: TransactionStatus.Cleared))
&& criteria.Sources.Contains(t.TransactionSource)
&& criteria.Types.Contains(t.TransactionType));