0
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小于等于或dtpToDatetxtSearch.TextInvoiceNoAlias

4

1 回答 1

4

不是ac.Where(expFromDate);
但是ac=ac.Where(expFromDate);

于 2013-11-09T08:10:32.067 回答