public List <CustomerContactViewModel> SearchAll(CustomerContactQueryCondition cond) { return(this.GetSearchIQuerable(cond).OrderByDescending(x => x.Id).AsNoTracking().Select(x => new CustomerContactViewModel() { CompanyNumber = x.客戶資料.統一編號, CustomerName = x.客戶資料.客戶名稱, Email = x.Email, Id = x.Id, 姓名 = x.姓名, 手機 = x.手機, 職稱 = x.職稱, 電話 = x.電話 }).ToList()); }
public IQueryable <客戶聯絡人> GetSearchIQuerable(CustomerContactQueryCondition cond) { var query = this.All(); if (cond != null) { query = query.Where(x => (string.IsNullOrEmpty(cond.CompanyNumber) || x.客戶資料.統一編號.Equals(cond.CompanyNumber)) && (string.IsNullOrEmpty(cond.CustomerName) || x.客戶資料.客戶名稱.Contains(cond.CustomerName)) && (string.IsNullOrEmpty(cond.ContactName) || x.姓名.Contains(cond.ContactName)) && (string.IsNullOrEmpty(cond.Email) || x.Email.Equals(cond.Email)) && (string.IsNullOrEmpty(cond.JobName) || x.職稱.Equals(cond.JobName)) && (string.IsNullOrEmpty(cond.Mobile) || x.手機.Equals(cond.Mobile)) && (string.IsNullOrEmpty(cond.Phone) || x.電話.Equals(cond.Phone))); } return(query); }
public List <CustomerContactViewModel> Search(CustomerContactQueryCondition cond, PagingViewModel paging, SortingViewModel sort) { return(this.GetSearchIQuerable(cond) .Sort(sort) .Skip(paging.Skip) .Take(paging.Take) .AsNoTracking() .Select(x => new CustomerContactViewModel() { CompanyNumber = x.客戶資料.統一編號, CustomerName = x.客戶資料.客戶名稱, Email = x.Email, Id = x.Id, 姓名 = x.姓名, 手機 = x.手機, 職稱 = x.職稱, 電話 = x.電話 }).ToList()); }
public int SearchCount(CustomerContactQueryCondition cond) { return(this.GetSearchIQuerable(cond).AsNoTracking().Count()); }