nullref fixes
This commit is contained in:
parent
fd5b7959c5
commit
fda37f0e15
3 changed files with 10 additions and 16 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -377,4 +377,5 @@ site/
|
|||
## AI
|
||||
|
||||
.aider.*
|
||||
PROMPT.md
|
||||
PROMPT.md
|
||||
.aider*
|
|
@ -10,28 +10,22 @@ public static class DbExtensions
|
|||
where T : DbEntity
|
||||
=> set.FirstOrDefault(x => x.Id == id);
|
||||
|
||||
public static GuildConfig GuildConfigsForId(this DbContext ctx, ulong guildId)
|
||||
{
|
||||
var query = ctx.Set<GuildConfig>().Where(gc => gc.GuildId == guildId);
|
||||
return query.FirstOrDefault();
|
||||
}
|
||||
|
||||
public static GuildFilterConfig FilterConfigForId(
|
||||
this DbContext ctx,
|
||||
ulong guildId,
|
||||
Func<IQueryable<GuildFilterConfig>, IQueryable<GuildFilterConfig>> includes = default)
|
||||
{
|
||||
includes ??= static set => set;
|
||||
|
||||
|
||||
var gfc = includes(ctx.Set<GuildFilterConfig>()
|
||||
.Where(gc => gc.GuildId == guildId))
|
||||
.Where(gc => gc.GuildId == guildId))
|
||||
.FirstOrDefault();
|
||||
|
||||
if (gfc is null)
|
||||
{
|
||||
ctx.Add(gfc = new GuildFilterConfig()
|
||||
ctx.Add(gfc = new()
|
||||
{
|
||||
GuildId = guildId
|
||||
GuildId = guildId,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -46,15 +40,14 @@ public static class DbExtensions
|
|||
includes ??= static set => set;
|
||||
|
||||
var gc = includes(ctx.Set<GuildConfig>()
|
||||
.Where(gc => gc.GuildId == guildId))
|
||||
.Where(gc => gc.GuildId == guildId))
|
||||
.FirstOrDefault();
|
||||
|
||||
if (gc is null)
|
||||
{
|
||||
ctx.Add(gc = new GuildConfig()
|
||||
ctx.Add(gc = new()
|
||||
{
|
||||
GuildId = guildId,
|
||||
Permissions = []
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -64,6 +64,6 @@ public class GuildConfig : DbEntity
|
|||
|
||||
public string TimeZoneId { get; set; }
|
||||
public string Locale { get; set; }
|
||||
|
||||
public List<Permissionv2> Permissions { get; set; }
|
||||
|
||||
public List<Permissionv2> Permissions { get; set; } = [];
|
||||
}
|
Loading…
Add table
Reference in a new issue