From 809582b02b7208419d7eb8fac78ec1cd9fcb453f Mon Sep 17 00:00:00 2001 From: Argo-Surface Date: Fri, 22 Feb 2019 16:27:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9BUG=EF=BC=9AMongoDB=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E4=B8=8B=E7=A8=8B=E5=BA=8F=E5=BC=82=E5=B8=B8=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E5=A2=9E=E5=8A=A0=E6=8E=92=E5=BA=8F=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=20#IRWZD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bootstrap.DataAccess.MongoDB/Exceptions.cs | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Bootstrap.DataAccess.MongoDB/Exceptions.cs b/Bootstrap.DataAccess.MongoDB/Exceptions.cs index c0e54c5a..dab2fa63 100644 --- a/Bootstrap.DataAccess.MongoDB/Exceptions.cs +++ b/Bootstrap.DataAccess.MongoDB/Exceptions.cs @@ -65,6 +65,30 @@ namespace Bootstrap.DataAccess.MongoDB public override Page RetrievePages(PaginationOption po, DateTime? startTime, DateTime? endTime) { var exceps = DbManager.Exceptions.Find(FilterDefinition.Empty).ToList(); + // sort + var orderProxy = po.Order == "asc" ? + new Func, List>(p => exceps.OrderBy(p).ToList()) : + new Func, List>(p => exceps.OrderByDescending(p).ToList()); + + var logTimeProxy = po.Order == "asc" ? + new Func, List>(p => exceps.OrderBy(p).ToList()) : + new Func, List>(p => exceps.OrderByDescending(p).ToList()); + + switch (po.Sort) + { + case "ErrorPage": + exceps = orderProxy(ex => ex.ErrorPage); + break; + case "UserId": + exceps = orderProxy(ex => ex.UserId); + break; + case "UserIp": + exceps = orderProxy(ex => ex.UserIp); + break; + case "LogTime": + exceps = logTimeProxy(ex => ex.LogTime); + break; + } return new Page() { Context = exceps,