1
0
mirror of https://github.com/wangdage12/Snap.Hutao.git synced 2026-06-06 09:51:06 +08:00

修复 rowid 翻译失败导致的崩溃

This commit is contained in:
mfkvfhpdx
2026-05-04 17:45:10 +08:00
parent f66d712a1b
commit 8588f7736a

View File

@@ -58,10 +58,18 @@ internal sealed partial class CultivationRepository : ICultivationRepository
using (IServiceScope scope = ServiceProvider.CreateScope())
{
AppDbContext db = scope.GetAppDbContext();
// EF Core 不会为 SQLite 的隐式 rowid 自动建模;这里用原生 SQL 取最新插入的一条。
return db.Set<CultivateEntry>()
.FromSqlInterpolated($"""
SELECT *
FROM cultivate_entries
WHERE ProjectId = {projectId}
AND Id = {avatarId}
AND Type = {(int)CultivateType.AvatarAndSkill}
ORDER BY rowid DESC
LIMIT 1
""")
.AsNoTracking()
.Where(e => e.ProjectId == projectId && e.Id == avatarId && e.Type == CultivateType.AvatarAndSkill)
.OrderByDescending(e => EF.Property<long>(e, "rowid"))
.Select(e => (Guid?)e.InnerId)
.FirstOrDefault();
}