Not ac.Where(expFromDate);
But ac=ac.Where(expFromDate);
Why does this expression not give me the expected result?
-
30-07-2022 - |
Domanda
Expression<Func<BAL.Receipt, bool>> expKeyword = x => x.InvoiceNo.StartsWith(txtSearch.Text) | x.Alias.StartsWith(txtSearch.Text);
Expression<Func<BAL.Receipt, bool>> expFromDate = x => x.Date > dtpFrom.DateTime.Date;
Expression<Func<BAL.Receipt, bool>> expToDate = x => x.Date <= dtpTo.DateTime;
var ac = BAL.ApplicationInfo.db.Receipts.Where(expKeyword);
if (dtpFrom.EditValue != null)
ac.Where(expFromDate);
if ( dtpTo.EditValue != null )
ac.Where(expToDate);
The expected result should return all the Receipts
with a date is greater than dtpFrom
date
and less than dtpToDate
and txtSearch.Text
equal to InvoiceNo
or Alias
Soluzione
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow