更新 AuthorizeApp.cs AuthoriseService.cs=>public List<ModuleElement> ModuleElements { get { return GetModuleElementsQuery().ToList(); } } 会导致重复查询数据库。在user.Modules较多的时候影响性能。

This commit is contained in:
四色鬼 2019-01-03 18:35:11 +08:00
parent ee5e0294ff
commit fd9bca23a7

View File

@ -1,4 +1,4 @@
using System.Linq;
using System.Linq;
using Infrastructure;
using OpenAuth.App.Response;
using OpenAuth.Repository.Domain;
@ -41,10 +41,12 @@ namespace OpenAuth.App
Roles = service.Roles
};
var ModuleElements=service.ModuleElements;
foreach (var moduleView in user.Modules)
{
moduleView.Elements =
service.ModuleElements.Where(u => u.ModuleId == moduleView.Id).OrderBy(u => u.Sort).ToList();
ModuleElements.Where(u => u.ModuleId == moduleView.Id).OrderBy(u => u.Sort).ToList();
}
return user;