[Workers] Use SQL raw.

This commit is contained in:
2025-07-07 20:45:31 +01:00
parent 55b4018ebd
commit 4f96535b51

View File

@@ -471,76 +471,76 @@ public sealed class DatImporter
List<DbFile> pendingFilesByCrcList = romsHaveCrc List<DbFile> pendingFilesByCrcList = romsHaveCrc
? ctx.Files ? ctx.Files
.FromSql($"SELECT DISTINCT f.* FROM Files AS f, [{tmpRomCrc32Table}] AS t WHERE f.Crc32 = t.Crc32 AND f.Size = t.Size") .FromSqlRaw($"SELECT DISTINCT f.* FROM Files AS f, [{tmpRomCrc32Table}] AS t WHERE f.Crc32 = t.Crc32 AND f.Size = t.Size")
.ToList() .ToList()
: []; : [];
List<DbFile> pendingFilesByMd5List = romsHaveMd5 List<DbFile> pendingFilesByMd5List = romsHaveMd5
? ctx.Files ? ctx.Files
.FromSql($"SELECT DISTINCT f.* FROM Files AS f, [{tmpRomMd5Table}] AS t WHERE f.Md5 = t.Md5 AND f.Size = t.Size") .FromSqlRaw($"SELECT DISTINCT f.* FROM Files AS f, [{tmpRomMd5Table}] AS t WHERE f.Md5 = t.Md5 AND f.Size = t.Size")
.ToList() .ToList()
: []; : [];
List<DbFile> pendingFilesBySha1List = List<DbFile> pendingFilesBySha1List =
romsHaveSha1 romsHaveSha1
? ctx.Files ? ctx.Files
.FromSql($"SELECT DISTINCT f.* FROM Files AS f, [{tmpRomSha1Table}] AS t WHERE f.Sha1 = t.Sha1 AND f.Size = t.Size") .FromSqlRaw($"SELECT DISTINCT f.* FROM Files AS f, [{tmpRomSha1Table}] AS t WHERE f.Sha1 = t.Sha1 AND f.Size = t.Size")
.ToList() .ToList()
: []; : [];
List<DbFile> pendingFilesBySha256List = List<DbFile> pendingFilesBySha256List =
romsHaveSha256 romsHaveSha256
? ctx.Files ? ctx.Files
.FromSql($"SELECT DISTINCT f.* FROM Files AS f, [{tmpRomSha256Table}] AS t WHERE f.Sha256 = t.Sha256 AND f.Size = t.Size") .FromSqlRaw($"SELECT DISTINCT f.* FROM Files AS f, [{tmpRomSha256Table}] AS t WHERE f.Sha256 = t.Sha256 AND f.Size = t.Size")
.ToList() .ToList()
: []; : [];
List<DbFile> pendingFilesBySha384List = List<DbFile> pendingFilesBySha384List =
romsHaveSha384 romsHaveSha384
? ctx.Files ? ctx.Files
.FromSql($"SELECT DISTINCT f.* FROM Files AS f, [{tmpRomSha384Table}] AS t WHERE f.Sha384 = t.Sha384 AND f.Size = t.Size") .FromSqlRaw($"SELECT DISTINCT f.* FROM Files AS f, [{tmpRomSha384Table}] AS t WHERE f.Sha384 = t.Sha384 AND f.Size = t.Size")
.ToList() .ToList()
: []; : [];
List<DbFile> pendingFilesBySha512List = List<DbFile> pendingFilesBySha512List =
romsHaveSha512 romsHaveSha512
? ctx.Files ? ctx.Files
.FromSql($"SELECT DISTINCT f.* FROM Files AS f, [{tmpRomSha512Table}] AS t WHERE f.Sha512 = t.Sha512 AND f.Size = t.Size") .FromSqlRaw($"SELECT DISTINCT f.* FROM Files AS f, [{tmpRomSha512Table}] AS t WHERE f.Sha512 = t.Sha512 AND f.Size = t.Size")
.ToList() .ToList()
: []; : [];
Dictionary<string, DbDisk> pendingDisksByMd5 = Dictionary<string, DbDisk> pendingDisksByMd5 =
disksHaveMd5 disksHaveMd5
? ctx.Disks ? ctx.Disks
.FromSql($"SELECT DISTINCT f.* FROM Disks AS f, [{tmpDiskMd5Table}] AS t WHERE f.Md5 = t.Md5") .FromSqlRaw($"SELECT DISTINCT f.* FROM Disks AS f, [{tmpDiskMd5Table}] AS t WHERE f.Md5 = t.Md5")
.ToDictionary(f => f.Md5) .ToDictionary(f => f.Md5)
: new Dictionary<string, DbDisk>(); : new Dictionary<string, DbDisk>();
Dictionary<string, DbDisk> pendingDisksBySha1 = Dictionary<string, DbDisk> pendingDisksBySha1 =
disksHaveSha1 disksHaveSha1
? ctx.Disks ? ctx.Disks
.FromSql($"SELECT DISTINCT f.* FROM Disks AS f, [{tmpDiskSha1Table}] AS t WHERE f.Sha1 = t.Sha1") .FromSqlRaw($"SELECT DISTINCT f.* FROM Disks AS f, [{tmpDiskSha1Table}] AS t WHERE f.Sha1 = t.Sha1")
.ToDictionary(f => f.Sha1) .ToDictionary(f => f.Sha1)
: new Dictionary<string, DbDisk>(); : new Dictionary<string, DbDisk>();
Dictionary<string, DbMedia> pendingMediasByMd5 = Dictionary<string, DbMedia> pendingMediasByMd5 =
mediasHaveMd5 mediasHaveMd5
? ctx.Medias ? ctx.Medias
.FromSql($"SELECT DISTINCT f.* FROM Medias AS f, [{tmpMediaMd5Table}] AS t WHERE f.Md5 = t.Md5") .FromSqlRaw($"SELECT DISTINCT f.* FROM Medias AS f, [{tmpMediaMd5Table}] AS t WHERE f.Md5 = t.Md5")
.ToDictionary(f => f.Md5) .ToDictionary(f => f.Md5)
: new Dictionary<string, DbMedia>(); : new Dictionary<string, DbMedia>();
Dictionary<string, DbMedia> pendingMediasBySha1 = Dictionary<string, DbMedia> pendingMediasBySha1 =
mediasHaveSha1 mediasHaveSha1
? ctx.Medias ? ctx.Medias
.FromSql($"SELECT DISTINCT f.* FROM Medias AS f, [{tmpMediaSha1Table}] AS t WHERE f.Sha1 = t.Sha1") .FromSqlRaw($"SELECT DISTINCT f.* FROM Medias AS f, [{tmpMediaSha1Table}] AS t WHERE f.Sha1 = t.Sha1")
.ToDictionary(f => f.Sha1) .ToDictionary(f => f.Sha1)
: new Dictionary<string, DbMedia>(); : new Dictionary<string, DbMedia>();
Dictionary<string, DbMedia> pendingMediasBySha256 = Dictionary<string, DbMedia> pendingMediasBySha256 =
mediasHaveSha256 mediasHaveSha256
? ctx.Medias ? ctx.Medias
.FromSql($"SELECT DISTINCT f.* FROM Medias AS f, [{tmpMediaSha256Table}] AS t WHERE f.Sha256 = t.Sha256") .FromSqlRaw($"SELECT DISTINCT f.* FROM Medias AS f, [{tmpMediaSha256Table}] AS t WHERE f.Sha256 = t.Sha256")
.ToDictionary(f => f.Sha256) .ToDictionary(f => f.Sha256)
: new Dictionary<string, DbMedia>(); : new Dictionary<string, DbMedia>();