public ResponsResult AdManagerList(AdManagerViewSearch model) { ResponsResult result = new ResponsResult(); var query = base.Query <Advertising>(); if (!string.IsNullOrEmpty(model.AdName)) { query = query.Where(t => t.AdName == model.AdName); } if ((int)model.AdLocation > 0) { query = query.Where(t => t.AdLocation == (int)model.AdLocation); } List <AdManagerViewSearch> _list = new List <AdManagerViewSearch>(); query.OrderByDescending(t => t.Id).Pages(model.PageIndex, model.PageSize, out int count).Select(t => new { t.Id, t.AdLocation, t.AdName, t.AdPic, t.BeginTime, t.EndTime, t.IsEnable, t.AdLink }).ToList().ForEach(t => { _list.Add( new AdManagerViewSearch { Id = t.Id, AdName = t.AdName, BeginTime = t.BeginTime, EndTime = t.EndTime, AdPic = t.AdPic, AdLocationName = JsonExtensions.GetString((AdLocation)t.AdLocation), IsEnable = (bool)t.IsEnable,//查询是几就是几 }); } ); result.Data = _list; result.RecordCount = count; return(result); }