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
|
## AI
|
||||||
|
|
||||||
.aider.*
|
.aider.*
|
||||||
PROMPT.md
|
PROMPT.md
|
||||||
|
.aider*
|
|
@ -10,28 +10,22 @@ public static class DbExtensions
|
||||||
where T : DbEntity
|
where T : DbEntity
|
||||||
=> set.FirstOrDefault(x => x.Id == id);
|
=> 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(
|
public static GuildFilterConfig FilterConfigForId(
|
||||||
this DbContext ctx,
|
this DbContext ctx,
|
||||||
ulong guildId,
|
ulong guildId,
|
||||||
Func<IQueryable<GuildFilterConfig>, IQueryable<GuildFilterConfig>> includes = default)
|
Func<IQueryable<GuildFilterConfig>, IQueryable<GuildFilterConfig>> includes = default)
|
||||||
{
|
{
|
||||||
includes ??= static set => set;
|
includes ??= static set => set;
|
||||||
|
|
||||||
var gfc = includes(ctx.Set<GuildFilterConfig>()
|
var gfc = includes(ctx.Set<GuildFilterConfig>()
|
||||||
.Where(gc => gc.GuildId == guildId))
|
.Where(gc => gc.GuildId == guildId))
|
||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
|
|
||||||
if (gfc is null)
|
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;
|
includes ??= static set => set;
|
||||||
|
|
||||||
var gc = includes(ctx.Set<GuildConfig>()
|
var gc = includes(ctx.Set<GuildConfig>()
|
||||||
.Where(gc => gc.GuildId == guildId))
|
.Where(gc => gc.GuildId == guildId))
|
||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
|
|
||||||
if (gc is null)
|
if (gc is null)
|
||||||
{
|
{
|
||||||
ctx.Add(gc = new GuildConfig()
|
ctx.Add(gc = new()
|
||||||
{
|
{
|
||||||
GuildId = guildId,
|
GuildId = guildId,
|
||||||
Permissions = []
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,6 @@ public class GuildConfig : DbEntity
|
||||||
|
|
||||||
public string TimeZoneId { get; set; }
|
public string TimeZoneId { get; set; }
|
||||||
public string Locale { 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