Отчистка кода
This commit is contained in:
@@ -1,8 +1,4 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Pf2eModel.Model.Structure;
|
||||
using static LinqToDB.Common.Configuration;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
using System.Buffers;
|
||||
|
||||
#nullable disable
|
||||
|
||||
@@ -14,7 +10,8 @@ public partial class Function : Migration
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.Sql("""
|
||||
migrationBuilder.Sql(
|
||||
"""
|
||||
CREATE OR REPLACE FUNCTION f_truncate_tables()
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql AS
|
||||
@@ -30,8 +27,10 @@ BEGIN
|
||||
);
|
||||
END
|
||||
$func$;
|
||||
""");
|
||||
migrationBuilder.Sql("""
|
||||
"""
|
||||
);
|
||||
migrationBuilder.Sql(
|
||||
"""
|
||||
CREATE OR REPLACE FUNCTION f_drop_tables()
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql AS
|
||||
@@ -46,8 +45,10 @@ BEGIN
|
||||
);
|
||||
END
|
||||
$func$;
|
||||
""");
|
||||
migrationBuilder.Sql("""
|
||||
"""
|
||||
);
|
||||
migrationBuilder.Sql(
|
||||
"""
|
||||
CREATE OR REPLACE FUNCTION f_permission_tables(_username text)
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql AS
|
||||
@@ -68,7 +69,8 @@ $func$;
|
||||
"""
|
||||
);
|
||||
|
||||
migrationBuilder.Sql("""
|
||||
migrationBuilder.Sql(
|
||||
"""
|
||||
CREATE OR REPLACE FUNCTION locale_search(data jsonb, search_value text)
|
||||
RETURNS boolean
|
||||
LANGUAGE plpgsql AS
|
||||
@@ -80,7 +82,8 @@ $func$;
|
||||
"""
|
||||
);
|
||||
|
||||
migrationBuilder.Sql("""
|
||||
migrationBuilder.Sql(
|
||||
"""
|
||||
CREATE OR REPLACE FUNCTION locale_search_array(data jsonb, search_values text[])
|
||||
RETURNS boolean
|
||||
LANGUAGE plpgsql AS
|
||||
@@ -95,7 +98,6 @@ END;
|
||||
$func$;
|
||||
"""
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
+1531
-1195
File diff suppressed because it is too large
Load Diff
@@ -1,30 +1,33 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Pf2eModel.Model.Base;
|
||||
using System.ComponentModel;
|
||||
using System.Linq.Expressions;
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Pf2eModel.Model.Common.I18n;
|
||||
|
||||
public static class LocaleExtension
|
||||
{
|
||||
public static string GetTypeString(this LocaleType localeType)
|
||||
{
|
||||
FieldInfo fi = localeType.GetType().GetField(localeType.ToString())!;
|
||||
|
||||
DescriptionAttribute[] attributes = (DescriptionAttribute[]) fi.GetCustomAttributes(typeof(DescriptionAttribute), false);
|
||||
DescriptionAttribute[] attributes = (DescriptionAttribute[])
|
||||
fi.GetCustomAttributes(typeof(DescriptionAttribute), false);
|
||||
|
||||
return (attributes.Length != 0 ? attributes.FirstOrDefault()?.Description : null) ?? localeType.ToString();
|
||||
return (attributes.Length != 0 ? attributes.FirstOrDefault()?.Description : null)
|
||||
?? localeType.ToString();
|
||||
}
|
||||
|
||||
public static LocaleType GetTypeByString(this string localeType)
|
||||
{
|
||||
foreach (System.Reflection.FieldInfo field in typeof(LocaleType).GetFields())
|
||||
{
|
||||
if (Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) is DescriptionAttribute descriptionAttribute)
|
||||
if (
|
||||
Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute))
|
||||
is DescriptionAttribute descriptionAttribute
|
||||
)
|
||||
{
|
||||
if (descriptionAttribute.Description == localeType)
|
||||
{
|
||||
return (LocaleType) field.GetValue(null)!;
|
||||
return (LocaleType)field.GetValue(null)!;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,12 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.Serialization.Json;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Pf2eModel.Model.Common.I18n;
|
||||
|
||||
public class LocaleString : ICollection<LocaleItem>
|
||||
{
|
||||
private readonly List<LocaleItem> _items = [];
|
||||
|
||||
private void AssureDefault()
|
||||
{
|
||||
if (_items.Count == 0)
|
||||
@@ -34,16 +28,19 @@ public class LocaleString : ICollection<LocaleItem>
|
||||
|
||||
private LocaleType _E(string localeString) => LocaleExtension.GetTypeByString(localeString);
|
||||
|
||||
private LocaleType RealLocale(LocaleType locale) => Contains(locale) ? locale : LocaleType.English;
|
||||
private LocaleType RealLocale(LocaleType locale) =>
|
||||
Contains(locale) ? locale : LocaleType.English;
|
||||
|
||||
private LocaleType RealLocale(string localeString) => RealLocale(_E(localeString));
|
||||
|
||||
public LocaleItem GetItem(LocaleType locale) => this.First(c => c.Locale == RealLocale(locale));
|
||||
|
||||
public LocaleItem GetItem(string locale) => this.First(c => c.Locale == RealLocale(locale));
|
||||
|
||||
public string this[LocaleType locale]
|
||||
{
|
||||
get => GetItem(locale).Value;
|
||||
set
|
||||
set
|
||||
{
|
||||
if (Types.Contains(locale))
|
||||
{
|
||||
@@ -65,6 +62,7 @@ public class LocaleString : ICollection<LocaleItem>
|
||||
{
|
||||
this[item.Locale] = item.Value;
|
||||
}
|
||||
|
||||
public void Add(LocaleType locale, string value)
|
||||
{
|
||||
this[locale] = value;
|
||||
@@ -80,10 +78,12 @@ public class LocaleString : ICollection<LocaleItem>
|
||||
{
|
||||
return _items.Contains(item);
|
||||
}
|
||||
|
||||
public bool Contains(LocaleType locale)
|
||||
{
|
||||
return Types.Contains(locale);
|
||||
}
|
||||
|
||||
public bool Contains(string value)
|
||||
{
|
||||
return this.Any(item => item.Value == value);
|
||||
@@ -111,6 +111,7 @@ public class LocaleString : ICollection<LocaleItem>
|
||||
{
|
||||
return _items.GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
@@ -132,17 +133,17 @@ public class LocaleString : ICollection<LocaleItem>
|
||||
|
||||
return json.ToString();
|
||||
}
|
||||
|
||||
public static LocaleString Deserialize(string input)
|
||||
{
|
||||
JObject json = JObject.Parse(input);
|
||||
LocaleString result = new();
|
||||
|
||||
foreach (var item in json)
|
||||
foreach (KeyValuePair<string, JToken?> item in json)
|
||||
{
|
||||
result[item.Key] = item.ToString();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
using Pf2eModel.Model.Base;
|
||||
using Pf2eModel.Model.Enum;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Pf2eModel.Model.Base;
|
||||
using Pf2eModel.Model.Enum;
|
||||
|
||||
namespace Pf2eModel.Model.Structure;
|
||||
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Pf2eModel.Model.Structure.ArchetypeRelation;
|
||||
|
||||
@@ -11,6 +6,6 @@ namespace Pf2eModel.Model.Structure.ArchetypeRelation;
|
||||
internal class ArchetypeFeats
|
||||
{
|
||||
public int ArchetypeId { get; set; }
|
||||
|
||||
|
||||
public int FeatId { get; set; }
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
using Pf2eModel.Model.Base;
|
||||
using Pf2eModel.Model.Enum;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Pf2eModel.Model.Base;
|
||||
using Pf2eModel.Model.Enum;
|
||||
|
||||
namespace Pf2eModel.Model.Structure;
|
||||
|
||||
[EntityOfType(EntityType.Language)]
|
||||
public partial class Language: IEntity
|
||||
public partial class Language : IEntity
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
@@ -14,5 +14,4 @@ public partial class Language: IEntity
|
||||
public int Id { get; set; }
|
||||
|
||||
public Entity Entity { get; set; } = null!;
|
||||
|
||||
}
|
||||
|
||||
+144
-65
@@ -1,6 +1,7 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using Microsoft.EntityFrameworkCore.Query.SqlExpressions;
|
||||
using Pf2eModel.Model;
|
||||
using Pf2eModel.Model.Base;
|
||||
using Pf2eModel.Model.Base.Keywords;
|
||||
@@ -17,8 +18,6 @@ using Pf2eModel.Model.Structure.ClassRelation;
|
||||
using Pf2eModel.Model.Structure.DeityRelation;
|
||||
using Pf2eModel.Model.Structure.FeatRelation;
|
||||
using Pf2eModel.Model.Structure.SpellRelation;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Pf2eModel;
|
||||
|
||||
@@ -37,15 +36,21 @@ public partial class Pf2eDbContext
|
||||
DefineMethods(modelBuilder);
|
||||
}
|
||||
|
||||
private void BindEntity<T>(EntityTypeBuilder<T> entity) where T : class, IEntity
|
||||
private void BindEntity<T>(EntityTypeBuilder<T> entity)
|
||||
where T : class, IEntity
|
||||
{
|
||||
entity.HasOne(entity => entity.Entity)
|
||||
entity
|
||||
.HasOne(entity => entity.Entity)
|
||||
.WithOne()
|
||||
.HasForeignKey<T>(entity => entity.Id)
|
||||
.IsRequired();
|
||||
}
|
||||
|
||||
private void BindLocaleString<T>(EntityTypeBuilder<T> entity, Expression<Func<T, LocaleString>> func) where T : class
|
||||
private void BindLocaleString<T>(
|
||||
EntityTypeBuilder<T> entity,
|
||||
Expression<Func<T, LocaleString>> func
|
||||
)
|
||||
where T : class
|
||||
{
|
||||
/*
|
||||
entity.OwnsMany(func, d =>
|
||||
@@ -54,11 +59,9 @@ public partial class Pf2eDbContext
|
||||
});
|
||||
*/
|
||||
|
||||
entity.Property(func)
|
||||
.HasConversion(
|
||||
v => v.Serialize(),
|
||||
v => LocaleString.Deserialize(v)
|
||||
)
|
||||
entity
|
||||
.Property(func)
|
||||
.HasConversion(v => v.Serialize(), v => LocaleString.Deserialize(v))
|
||||
.HasColumnType("jsonb");
|
||||
}
|
||||
|
||||
@@ -84,8 +87,7 @@ public partial class Pf2eDbContext
|
||||
.HasPostgresEnum<SpellDamageKinds>()
|
||||
.HasPostgresEnum<AttributeValues>()
|
||||
.HasPostgresEnum<TrainingStage>()
|
||||
.HasPostgresEnum<SourceCategory>()
|
||||
;
|
||||
.HasPostgresEnum<SourceCategory>();
|
||||
}
|
||||
|
||||
private void DefineBase(ModelBuilder modelBuilder)
|
||||
@@ -99,12 +101,16 @@ public partial class Pf2eDbContext
|
||||
entity.HasMany(e => e.Keywords).WithMany(t => t.Entities);
|
||||
|
||||
// EntitySource
|
||||
entity.HasMany(e => e.Sources).WithOne(e => e.Entity)
|
||||
entity
|
||||
.HasMany(e => e.Sources)
|
||||
.WithOne(e => e.Entity)
|
||||
.HasForeignKey(e => e.EntityId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
// EntityExternal
|
||||
entity.HasMany(e => e.Externals).WithOne(e => e.Entity)
|
||||
entity
|
||||
.HasMany(e => e.Externals)
|
||||
.WithOne(e => e.Entity)
|
||||
.HasForeignKey(e => e.EntityId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
@@ -114,7 +120,9 @@ public partial class Pf2eDbContext
|
||||
{
|
||||
entity.Property(e => e.Id).HasColumnName("id");
|
||||
|
||||
entity.HasMany(s => s.EntitySources).WithOne(e => e.Source)
|
||||
entity
|
||||
.HasMany(s => s.EntitySources)
|
||||
.WithOne(e => e.Source)
|
||||
.HasForeignKey(e => e.SourceId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
@@ -125,7 +133,9 @@ public partial class Pf2eDbContext
|
||||
// External
|
||||
modelBuilder.Entity<ExternalTarget>(entity =>
|
||||
{
|
||||
entity.HasMany(t => t.EntityExternals).WithOne(e => e.Target)
|
||||
entity
|
||||
.HasMany(t => t.EntityExternals)
|
||||
.WithOne(e => e.Target)
|
||||
.HasForeignKey(e => e.TargetId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
@@ -134,7 +144,9 @@ public partial class Pf2eDbContext
|
||||
// Keywords
|
||||
modelBuilder.Entity<Keyword>(entity =>
|
||||
{
|
||||
entity.HasMany(e => e.Aliases).WithOne(e => e.Keyword)
|
||||
entity
|
||||
.HasMany(e => e.Aliases)
|
||||
.WithOne(e => e.Keyword)
|
||||
.HasForeignKey(e => e.KeywordId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
@@ -163,28 +175,38 @@ public partial class Pf2eDbContext
|
||||
{
|
||||
BindEntity(entity);
|
||||
|
||||
entity.HasMany(e => e.AncestryBoosts).WithOne(e => e.Ancestry)
|
||||
entity
|
||||
.HasMany(e => e.AncestryBoosts)
|
||||
.WithOne(e => e.Ancestry)
|
||||
.HasForeignKey(e => e.AncestryId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
entity.HasMany(e => e.AncestryItems).WithOne(e => e.Ancestry)
|
||||
entity
|
||||
.HasMany(e => e.AncestryItems)
|
||||
.WithOne(e => e.Ancestry)
|
||||
.HasForeignKey(e => e.AncestryId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
entity.HasMany(e => e.AncestryLanguages).WithOne(e => e.Ancestry)
|
||||
entity
|
||||
.HasMany(e => e.AncestryLanguages)
|
||||
.WithOne(e => e.Ancestry)
|
||||
.HasForeignKey(e => e.AncestryId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
modelBuilder.Entity<AncestryBoost>(entity => { });
|
||||
modelBuilder.Entity<AncestryItem>(entity =>
|
||||
{
|
||||
entity.HasOne(d => d.Item).WithMany()
|
||||
entity
|
||||
.HasOne(d => d.Item)
|
||||
.WithMany()
|
||||
.HasForeignKey(d => d.ItemId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
modelBuilder.Entity<AncestryLanguage>(entity =>
|
||||
{
|
||||
entity.HasOne(d => d.Language).WithMany()
|
||||
entity
|
||||
.HasOne(d => d.Language)
|
||||
.WithMany()
|
||||
.HasForeignKey(d => d.LanguageId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
@@ -194,11 +216,15 @@ public partial class Pf2eDbContext
|
||||
{
|
||||
BindEntity(entity);
|
||||
|
||||
entity.HasOne(a => a.DedicationFeat).WithOne()
|
||||
entity
|
||||
.HasOne(a => a.DedicationFeat)
|
||||
.WithOne()
|
||||
.HasForeignKey<Archetype>(a => a.DedicationFeatId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
entity.HasMany(a => a.Feats).WithMany(f => f.Archetypes)
|
||||
entity
|
||||
.HasMany(a => a.Feats)
|
||||
.WithMany(f => f.Archetypes)
|
||||
.UsingEntity<ArchetypeFeats>(
|
||||
l => l.HasOne<Feat>().WithMany().HasForeignKey(af => af.FeatId),
|
||||
r => r.HasOne<Archetype>().WithMany().HasForeignKey(af => af.ArchetypeId)
|
||||
@@ -212,23 +238,31 @@ public partial class Pf2eDbContext
|
||||
});
|
||||
modelBuilder.Entity<BackgroundBoost>(entity =>
|
||||
{
|
||||
entity.HasOne(d => d.Background).WithMany(p => p.BackgroundBoosts)
|
||||
entity
|
||||
.HasOne(d => d.Background)
|
||||
.WithMany(p => p.BackgroundBoosts)
|
||||
.HasForeignKey(d => d.BackgroundId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
modelBuilder.Entity<BackgroundItem>(entity =>
|
||||
{
|
||||
entity.HasOne(d => d.Background).WithMany(p => p.BackgroundItems)
|
||||
entity
|
||||
.HasOne(d => d.Background)
|
||||
.WithMany(p => p.BackgroundItems)
|
||||
.HasForeignKey(d => d.BackgroundId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
entity.HasOne(d => d.Entity).WithMany()
|
||||
entity
|
||||
.HasOne(d => d.Entity)
|
||||
.WithMany()
|
||||
.HasForeignKey(d => d.EntityId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
modelBuilder.Entity<BackgroundTraining>(entity =>
|
||||
{
|
||||
entity.HasOne(d => d.Background).WithMany(p => p.BackgroundSkills)
|
||||
entity
|
||||
.HasOne(d => d.Background)
|
||||
.WithMany(p => p.BackgroundSkills)
|
||||
.HasForeignKey(d => d.BackgroundId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
@@ -240,27 +274,37 @@ public partial class Pf2eDbContext
|
||||
});
|
||||
modelBuilder.Entity<ClassKeyAbility>(entity =>
|
||||
{
|
||||
entity.HasOne(d => d.Class).WithMany(p => p.ClassKeyAbilities)
|
||||
entity
|
||||
.HasOne(d => d.Class)
|
||||
.WithMany(p => p.ClassKeyAbilities)
|
||||
.HasForeignKey(d => d.ClassId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
modelBuilder.Entity<ClassProgression>(entity =>
|
||||
{
|
||||
entity.HasOne(d => d.Class).WithMany(p => p.ClassProgressions)
|
||||
entity
|
||||
.HasOne(d => d.Class)
|
||||
.WithMany(p => p.ClassProgressions)
|
||||
.HasForeignKey(d => d.ClassId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
entity.HasOne(d => d.Entity).WithMany()
|
||||
entity
|
||||
.HasOne(d => d.Entity)
|
||||
.WithMany()
|
||||
.HasForeignKey(d => d.EntityId)
|
||||
.OnDelete(DeleteBehavior.SetNull);
|
||||
});
|
||||
modelBuilder.Entity<ClassTraining>(entity =>
|
||||
{
|
||||
entity.HasOne(d => d.Class).WithMany(p => p.ClassTrainings)
|
||||
entity
|
||||
.HasOne(d => d.Class)
|
||||
.WithMany(p => p.ClassTrainings)
|
||||
.HasForeignKey(d => d.ClassId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
entity.HasOne(d => d.Training).WithMany()
|
||||
entity
|
||||
.HasOne(d => d.Training)
|
||||
.WithMany()
|
||||
.HasForeignKey(d => d.TrainingId)
|
||||
.OnDelete(DeleteBehavior.SetNull);
|
||||
});
|
||||
@@ -276,19 +320,27 @@ public partial class Pf2eDbContext
|
||||
{
|
||||
BindEntity(entity);
|
||||
|
||||
entity.HasMany(e => e.DeityAttributes).WithOne(e => e.Deity)
|
||||
entity
|
||||
.HasMany(e => e.DeityAttributes)
|
||||
.WithOne(e => e.Deity)
|
||||
.HasForeignKey(e => e.DeityId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
entity.HasMany(e => e.DeityDomains).WithOne(e => e.Deity)
|
||||
entity
|
||||
.HasMany(e => e.DeityDomains)
|
||||
.WithOne(e => e.Deity)
|
||||
.HasForeignKey(e => e.DeityId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
entity.HasMany(e => e.DeitySpells).WithOne(e => e.Deity)
|
||||
entity
|
||||
.HasMany(e => e.DeitySpells)
|
||||
.WithOne(e => e.Deity)
|
||||
.HasForeignKey(e => e.DeityId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
entity.HasMany(e => e.DeityWeapons).WithOne(e => e.Deity)
|
||||
entity
|
||||
.HasMany(e => e.DeityWeapons)
|
||||
.WithOne(e => e.Deity)
|
||||
.HasForeignKey(e => e.DeityId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
@@ -298,7 +350,9 @@ public partial class Pf2eDbContext
|
||||
modelBuilder.Entity<DeityDomain>(entity => { });
|
||||
modelBuilder.Entity<DeitySpell>(entity =>
|
||||
{
|
||||
entity.HasOne(d => d.Spell).WithMany()
|
||||
entity
|
||||
.HasOne(d => d.Spell)
|
||||
.WithMany()
|
||||
.HasForeignKey(d => d.SpellId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
@@ -309,7 +363,9 @@ public partial class Pf2eDbContext
|
||||
{
|
||||
BindEntity(entity);
|
||||
|
||||
entity.HasMany(e => e.FeatPrerequisites).WithOne(e => e.Feat)
|
||||
entity
|
||||
.HasMany(e => e.FeatPrerequisites)
|
||||
.WithOne(e => e.Feat)
|
||||
.HasForeignKey(e => e.FeatId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
@@ -320,7 +376,9 @@ public partial class Pf2eDbContext
|
||||
{
|
||||
BindEntity(entity);
|
||||
|
||||
entity.HasOne(d => d.Ancestry).WithMany(p => p.Heritages)
|
||||
entity
|
||||
.HasOne(d => d.Ancestry)
|
||||
.WithMany(p => p.Heritages)
|
||||
.HasForeignKey(d => d.AncestryId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
@@ -330,21 +388,29 @@ public partial class Pf2eDbContext
|
||||
{
|
||||
BindEntity(entity);
|
||||
|
||||
entity.HasOne(e => e.SpellArea).WithOne(e => e.Spell)
|
||||
entity
|
||||
.HasOne(e => e.SpellArea)
|
||||
.WithOne(e => e.Spell)
|
||||
.HasForeignKey<SpellArea>(e => e.SpellId)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired(false);
|
||||
|
||||
entity.HasOne(e => e.SpellRitual).WithOne(e => e.Spell)
|
||||
entity
|
||||
.HasOne(e => e.SpellRitual)
|
||||
.WithOne(e => e.Spell)
|
||||
.HasForeignKey<SpellRitual>(e => e.SpellId)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired(false);
|
||||
|
||||
entity.HasMany(e => e.SpellDamages).WithOne(e => e.Spell)
|
||||
entity
|
||||
.HasMany(e => e.SpellDamages)
|
||||
.WithOne(e => e.Spell)
|
||||
.HasForeignKey(e => e.SpellId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
entity.HasMany(e => e.SpellDefenses).WithOne(e => e.Spell)
|
||||
entity
|
||||
.HasMany(e => e.SpellDefenses)
|
||||
.WithOne(e => e.Spell)
|
||||
.HasForeignKey(e => e.SpellId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
@@ -362,27 +428,40 @@ public partial class Pf2eDbContext
|
||||
|
||||
private void DefineMethods(ModelBuilder modelBuilder)
|
||||
{
|
||||
MethodInfo localeSearch = typeof(Pf2eDbContext).GetMethod(nameof(LocaleSearch), BindingFlags.Static | BindingFlags.Public, [typeof(LocaleString), typeof(string)])!;
|
||||
modelBuilder.HasDbFunction(localeSearch, builder =>
|
||||
{
|
||||
builder.HasName("locale_search");
|
||||
builder.HasParameter("data").HasStoreType("jsonb");
|
||||
builder.HasParameter("search_value");
|
||||
});
|
||||
MethodInfo localeSearch = typeof(Pf2eDbContext).GetMethod(
|
||||
nameof(LocaleSearch),
|
||||
BindingFlags.Static | BindingFlags.Public,
|
||||
[typeof(LocaleString), typeof(string)]
|
||||
)!;
|
||||
modelBuilder.HasDbFunction(
|
||||
localeSearch,
|
||||
builder =>
|
||||
{
|
||||
builder.HasName("locale_search");
|
||||
builder.HasParameter("data").HasStoreType("jsonb");
|
||||
builder.HasParameter("search_value");
|
||||
}
|
||||
);
|
||||
|
||||
MethodInfo localeSearchArray = typeof(Pf2eDbContext).GetMethod(nameof(LocaleSearchArray), BindingFlags.Static | BindingFlags.Public, [typeof(LocaleString), typeof(IEnumerable<string>)])!;
|
||||
modelBuilder.HasDbFunction(localeSearchArray, builder =>
|
||||
{
|
||||
builder.HasName("locale_search_array");
|
||||
builder.HasParameter("data").HasStoreType("jsonb");
|
||||
builder.HasParameter("search_values");
|
||||
});
|
||||
MethodInfo localeSearchArray = typeof(Pf2eDbContext).GetMethod(
|
||||
nameof(LocaleSearchArray),
|
||||
BindingFlags.Static | BindingFlags.Public,
|
||||
[typeof(LocaleString), typeof(IEnumerable<string>)]
|
||||
)!;
|
||||
modelBuilder.HasDbFunction(
|
||||
localeSearchArray,
|
||||
builder =>
|
||||
{
|
||||
builder.HasName("locale_search_array");
|
||||
builder.HasParameter("data").HasStoreType("jsonb");
|
||||
builder.HasParameter("search_values");
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public static bool LocaleSearch(LocaleString data, string search_value)
|
||||
=> throw new InvalidOperationException("Only for LINQ translation");
|
||||
|
||||
public static bool LocaleSearchArray(LocaleString data, IEnumerable<string> search_values)
|
||||
=> throw new InvalidOperationException("Only for LINQ translation");
|
||||
public static bool LocaleSearch(LocaleString data, string search_value) =>
|
||||
throw new InvalidOperationException("Only for LINQ translation");
|
||||
|
||||
public static bool LocaleSearchArray(LocaleString data, IEnumerable<string> search_values) =>
|
||||
throw new InvalidOperationException("Only for LINQ translation");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user