diff --git a/App/Modules/Cyan/Data/Repositories/PluginRepository.cs b/App/Modules/Cyan/Data/Repositories/PluginRepository.cs index 6900eb5..d5f464e 100644 --- a/App/Modules/Cyan/Data/Repositories/PluginRepository.cs +++ b/App/Modules/Cyan/Data/Repositories/PluginRepository.cs @@ -411,17 +411,19 @@ public async Task>> GetAllVersion(IEn : c.Or(x => x.Plugin.Name == r.Name && x.Plugin.User.Username == r.Username) ); - query = query.Where(predicate) + var all = await query.Where(predicate).ToArrayAsync(); + var grouped = all .GroupBy(x => new { x.Plugin.Name, x.Plugin.User.Username }) - .Select(g => g.OrderByDescending(o => o.Version).First()); + .Select(g => g.OrderByDescending(o => o.Version).First()) + .ToArray(); - var plugins = await query.Select(x => x.ToPrincipal()).ToArrayAsync(); + var plugins = grouped.Select(x => x.ToPrincipal()).ToArray(); this._logger.LogInformation("Plugin References: {@PluginReferences}", plugins.Select(x => x.Id)); if (plugins.Length != pluginRefs.Length) { - var found = await query.Select(x => $"{x.Plugin.User.Username}/{x.Plugin.Name}:{x.Version}").ToArrayAsync(); + var found = grouped.Select(x => $"{x.Plugin.User.Username}/{x.Plugin.Name}:{x.Version}").ToArray(); var search = pluginRefs.Select(x => $"{x.Username}/{x.Name}:{x.Version}"); var notFound = search.Except(found); return new MultipleEntityNotFound("Plugins not found", typeof(PluginPrincipal), notFound.ToArray(), diff --git a/App/Modules/Cyan/Data/Repositories/ProcessorRepository.cs b/App/Modules/Cyan/Data/Repositories/ProcessorRepository.cs index 96a64e4..49b99cb 100644 --- a/App/Modules/Cyan/Data/Repositories/ProcessorRepository.cs +++ b/App/Modules/Cyan/Data/Repositories/ProcessorRepository.cs @@ -415,22 +415,24 @@ public async Task>> GetAllVersion( : c.Or(x => x.Processor.Name == r.Name && x.Processor.User.Username == r.Username) ); - query = query.Where(predicate) + var all = await query.Where(predicate).ToArrayAsync(); + var grouped = all .GroupBy(x => new { x.Processor.Name, x.Processor.User.Username }) - .Select(g => g.OrderByDescending(o => o.Version).First()); + .Select(g => g.OrderByDescending(o => o.Version).First()) + .ToArray(); - var processors = await query.Select(x => x.ToPrincipal()).ToArrayAsync(); + var processors = grouped.Select(x => x.ToPrincipal()).ToArray(); this._logger.LogInformation("Processor References: {@ProcessorReferences}", processors.Select(x => x.Id)); if (processors.Length != processorRefs.Length) { - var found = await query.Select(x => $"{x.Processor.User.Username}/{x.Processor.Name}:{x.Version}") - .ToArrayAsync(); + var found = grouped.Select(x => $"{x.Processor.User.Username}/{x.Processor.Name}:{x.Version}").ToArray(); var search = processorRefs.Select(x => $"{x.Username}/{x.Name}:{x.Version}"); var notFound = search.Except(found).ToArray(); return new MultipleEntityNotFound("Processors not found", typeof(ProcessorPrincipal), notFound, found) .ToException(); } + return processors; } catch (Exception e)