public async Task <QueryResultModel <LoginLogEntity> > Query(LoginLogQueryModel model) { var paging = model.Paging(); var query = dbSet.AsQueryable(); if (!model.LoginName.IsNull()) { query = query.Where(a => a.LoginName.Equals(model.LoginName)); } if (!model.LoginIp.IsNull()) { query = query.Where(a => a.LoginIp.Equals(model.LoginIp)); } if (model.time_min != null) { query = query.Where(a => model.time_min < a.LoginTime); } if (model.time_max != null) { query = query.Where(a => model.time_max > a.LoginTime); } if (!paging.OrderBy.Any()) { query = query.OrderByDescending(m => m.Id); } return(await query.PaginationGetResult(paging)); }
public async Task <IList <LoginLogEntity> > Query(LoginLogQueryModel model) { var paging = model.Paging(); var query = Db.Find(); query.WhereNotNull(model.AccountId, m => m.AccountId == model.AccountId.Value); query.WhereNotNull(model.Platform, m => m.Platform == model.Platform.Value); query.WhereNotNull(model.LoginMode, m => m.LoginMode == model.LoginMode.Value); query.WhereNotNull(model.StartDate, m => m.LoginTime >= model.StartDate.Value.Date); query.WhereNotNull(model.EndDate, m => m.LoginTime < model.EndDate.Value.Date.AddDays(1)); if (!paging.OrderBy.Any()) { query.OrderByDescending(m => m.Id); } //导出全部 if (model.IsExport && model.Export.Mode == ExportMode.All) { model.ExportCount = await query.CountAsync(); if (model.IsOutOfExportCountLimit) { return(new List <LoginLogEntity>()); } return(await query.ToListAsync()); } var list = await query.PaginationAsync(paging); model.TotalCount = paging.TotalCount; return(list); }