Question

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

Était-ce utile?

La solution

Not ac.Where(expFromDate);
But ac=ac.Where(expFromDate);

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top