mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Fix some complex LINQ queries not convertible to SQL.
This commit is contained in:
@@ -14,19 +14,20 @@ namespace Marechai.Services
|
||||
public ResolutionsByGpuService(MarechaiContext context) => _context = context;
|
||||
|
||||
public async Task<List<ResolutionByGpuViewModel>> GetByGpu(int resolutionId) =>
|
||||
await _context.ResolutionsByGpu.Where(r => r.ResolutionId == resolutionId).
|
||||
Select(r => new ResolutionByGpuViewModel
|
||||
{
|
||||
Id = r.Id, GpuId = r.GpuId, Resolution = new ResolutionViewModel
|
||||
{
|
||||
Id = r.Resolution.Id, Width = r.Resolution.Width, Height = r.Resolution.Height,
|
||||
Colors = r.Resolution.Colors, Palette = r.Resolution.Palette,
|
||||
Chars = r.Resolution.Chars, Grayscale = r.Resolution.Grayscale
|
||||
},
|
||||
ResolutionId = r.ResolutionId
|
||||
}).OrderBy(r => r.Resolution.Width).ThenBy(r => r.Resolution.Height).
|
||||
ThenBy(r => r.Resolution.Chars).ThenBy(r => r.Resolution.Grayscale).
|
||||
ThenBy(r => r.Resolution.Colors).ThenBy(r => r.Resolution.Palette).ToListAsync();
|
||||
(await _context.ResolutionsByGpu.Where(r => r.ResolutionId == resolutionId).
|
||||
Select(r => new ResolutionByGpuViewModel
|
||||
{
|
||||
Id = r.Id, GpuId = r.GpuId, Resolution = new ResolutionViewModel
|
||||
{
|
||||
Id = r.Resolution.Id, Width = r.Resolution.Width, Height = r.Resolution.Height,
|
||||
Colors = r.Resolution.Colors, Palette = r.Resolution.Palette,
|
||||
Chars = r.Resolution.Chars, Grayscale = r.Resolution.Grayscale
|
||||
},
|
||||
ResolutionId = r.ResolutionId
|
||||
}).ToListAsync()).OrderBy(r => r.Resolution.Width).ThenBy(r => r.Resolution.Height).
|
||||
ThenBy(r => r.Resolution.Chars).ThenBy(r => r.Resolution.Grayscale).
|
||||
ThenBy(r => r.Resolution.Colors).ThenBy(r => r.Resolution.Palette).
|
||||
ToList();
|
||||
|
||||
public async Task DeleteAsync(long id)
|
||||
{
|
||||
|
||||
@@ -14,19 +14,20 @@ namespace Marechai.Services
|
||||
public ResolutionsByScreenService(MarechaiContext context) => _context = context;
|
||||
|
||||
public async Task<List<ResolutionByScreenViewModel>> GetByScreen(int resolutionId) =>
|
||||
await _context.ResolutionsByScreen.Where(r => r.ResolutionId == resolutionId).
|
||||
Select(r => new ResolutionByScreenViewModel
|
||||
{
|
||||
Id = r.Id, ScreenId = r.ScreenId, Resolution = new ResolutionViewModel
|
||||
{
|
||||
Id = r.Resolution.Id, Width = r.Resolution.Width, Height = r.Resolution.Height,
|
||||
Colors = r.Resolution.Colors, Palette = r.Resolution.Palette,
|
||||
Chars = r.Resolution.Chars, Grayscale = r.Resolution.Grayscale
|
||||
},
|
||||
ResolutionId = r.ResolutionId
|
||||
}).OrderBy(r => r.Resolution.Width).ThenBy(r => r.Resolution.Height).
|
||||
ThenBy(r => r.Resolution.Chars).ThenBy(r => r.Resolution.Grayscale).
|
||||
ThenBy(r => r.Resolution.Colors).ThenBy(r => r.Resolution.Palette).ToListAsync();
|
||||
(await _context.ResolutionsByScreen.Where(r => r.ResolutionId == resolutionId).
|
||||
Select(r => new ResolutionByScreenViewModel
|
||||
{
|
||||
Id = r.Id, ScreenId = r.ScreenId, Resolution = new ResolutionViewModel
|
||||
{
|
||||
Id = r.Resolution.Id, Width = r.Resolution.Width, Height = r.Resolution.Height,
|
||||
Colors = r.Resolution.Colors, Palette = r.Resolution.Palette,
|
||||
Chars = r.Resolution.Chars, Grayscale = r.Resolution.Grayscale
|
||||
},
|
||||
ResolutionId = r.ResolutionId
|
||||
}).ToListAsync()).OrderBy(r => r.Resolution.Width).ThenBy(r => r.Resolution.Height).
|
||||
ThenBy(r => r.Resolution.Chars).ThenBy(r => r.Resolution.Grayscale).
|
||||
ThenBy(r => r.Resolution.Colors).ThenBy(r => r.Resolution.Palette).
|
||||
ToList();
|
||||
|
||||
public async Task DeleteAsync(long id)
|
||||
{
|
||||
|
||||
@@ -13,38 +13,29 @@ namespace Marechai.Services
|
||||
|
||||
public ScreensService(MarechaiContext context) => _context = context;
|
||||
|
||||
public async Task<List<ScreenViewModel>> GetAsync() => await _context.Screens.Select(s => new ScreenViewModel
|
||||
{
|
||||
Diagonal = s.Diagonal,
|
||||
EffectiveColors = s.EffectiveColors,
|
||||
Height = s.Height, Id = s.Id,
|
||||
Type = s.Type, Width = s.Width,
|
||||
NativeResolutionId =
|
||||
s.NativeResolutionId,
|
||||
NativeResolution =
|
||||
new ResolutionViewModel
|
||||
{
|
||||
Chars = s.NativeResolution.
|
||||
Chars,
|
||||
Colors = s.NativeResolution.
|
||||
Colors,
|
||||
Grayscale = s.
|
||||
NativeResolution.
|
||||
Grayscale,
|
||||
Height = s.NativeResolution.
|
||||
Height,
|
||||
Id = s.NativeResolution.Id,
|
||||
Palette = s.NativeResolution.
|
||||
Palette,
|
||||
Width = s.NativeResolution.
|
||||
Width
|
||||
}
|
||||
}).OrderBy(s => s.Diagonal).
|
||||
ThenBy(s => s.EffectiveColors).
|
||||
ThenBy(s => s.NativeResolution.
|
||||
ToString()).
|
||||
ThenBy(s => s.Type).ThenBy(s => s.Size).
|
||||
ToListAsync();
|
||||
public async Task<List<ScreenViewModel>> GetAsync() => (await _context.Screens.Select(s => new ScreenViewModel
|
||||
{
|
||||
Diagonal = s.Diagonal,
|
||||
EffectiveColors = s.EffectiveColors,
|
||||
Height = s.Height, Id = s.Id, Type = s.Type,
|
||||
Width = s.Width,
|
||||
NativeResolutionId = s.NativeResolutionId,
|
||||
NativeResolution = new ResolutionViewModel
|
||||
{
|
||||
Chars = s.NativeResolution.Chars,
|
||||
Colors = s.NativeResolution.Colors,
|
||||
Grayscale = s.NativeResolution.Grayscale,
|
||||
Height = s.NativeResolution.Height,
|
||||
Id = s.NativeResolution.Id,
|
||||
Palette = s.NativeResolution.Palette,
|
||||
Width = s.NativeResolution.Width
|
||||
}
|
||||
}).ToListAsync()).OrderBy(s => s.Diagonal).
|
||||
ThenBy(s => s.EffectiveColors).
|
||||
ThenBy(s => s.NativeResolution.
|
||||
ToString()).
|
||||
ThenBy(s => s.Type).
|
||||
ThenBy(s => s.Size).ToList();
|
||||
|
||||
public async Task<ScreenViewModel> GetAsync(int id) =>
|
||||
await _context.Screens.Where(s => s.Id == id).Select(s => new ScreenViewModel
|
||||
|
||||
Reference in New Issue
Block a user