public List <BankAccountViewModel> Search(BankAccountQueryCondition cond) { return(this.GetSearchIQuerable(cond).OrderByDescending(x => x.Id).AsNoTracking().Select(x => new BankAccountViewModel() { AccountName = x.帳戶名稱, AccountNumber = x.帳戶號碼, BankCode = x.銀行代碼, BankName = x.銀行名稱, BankSubCode = x.分行代碼, CompanyNumber = x.客戶資料.統一編號, CustomerName = x.客戶資料.客戶名稱, Id = x.Id }).ToList()); }
public IQueryable <客戶銀行資訊> GetSearchIQuerable(BankAccountQueryCondition cond) { var query = this.All(); if (cond != null) { query = query.Where(x => (string.IsNullOrEmpty(cond.AccountName) || x.帳戶名稱.Equals(cond.AccountName)) && (string.IsNullOrEmpty(cond.AccountNumber) || x.帳戶號碼.Equals(cond.AccountNumber)) && (!cond.BankCode.HasValue || x.銀行代碼 == cond.BankCode.Value) && (!cond.BankSubCode.HasValue || x.分行代碼 == cond.BankSubCode.Value) && (string.IsNullOrEmpty(cond.BankName) || x.銀行名稱.Contains(cond.BankName)) && (string.IsNullOrEmpty(cond.CompanyNumber) || x.客戶資料.統一編號.Equals(cond.CompanyNumber)) && (string.IsNullOrEmpty(cond.CustomerName) || x.客戶資料.客戶名稱.Contains(cond.CustomerName)) ); } return(query); }
public int SearchCount(BankAccountQueryCondition cond) { return(this.GetSearchIQuerable(cond).OrderByDescending(x => x.Id).AsNoTracking().Count()); }