public List <WS_AccountBusiness> GetWS_AccountBusiness(int accountId, string betId, string busId, DateTime dtStart, DateTime dtEnd, int type) { using (e = new LotteryAPPEntities()) { long id = 0; long eId = 0; dtStart = dtStart.Date; dtEnd = dtEnd.Date.AddDays(1); var query = e.AccountBusiness.Where(n => n.AccountId == accountId && n.CreateTime >= dtStart && n.CreateTime < dtEnd); if (long.TryParse(betId, out eId)) { query = query.Where(n => n.EventId == eId); } if (long.TryParse(busId, out id)) { query = query.Where(n => n.Id == id); } if (type != 0) { query = query.Where(n => n.BusinessTypeId == type); } var list = (from a in query from b in e.Accounts where a.AccountId == b.Id orderby a.Id descending select new WS_AccountBusiness { AccountName = b.AccountName, BusinessTypeId = a.BusinessTypeId, CreateTime = a.CreateTime, PayAfter = a.PayAfter, PayBefore = a.PayBefore, EventId = a.EventId, PayIn = a.PayIn, PayOut = a.PayOut, Id = a.Id, }).ToList(); list.ForEach(n => n.BusinessTypeStr = EnumTool.GetBusinessType(n.BusinessTypeId)); return(list); } }