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);
预期结果应返回所有Receipts
日期大于日期且dtpFrom
小于等于或dtpToDate
txtSearch.Text
InvoiceNo
Alias