Большой рефактор
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Linq.Expressions;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
@@ -21,6 +22,7 @@ using Pf2eModel.Model.Structure.SpellRelation;
|
||||
|
||||
namespace Pf2eModel;
|
||||
|
||||
[SuppressMessage("ReSharper", "UnusedParameter.Local")]
|
||||
public partial class Pf2eDbContext
|
||||
{
|
||||
public const int NameLength = 255;
|
||||
@@ -39,11 +41,7 @@ public partial class Pf2eDbContext
|
||||
private void BindEntity<T>(EntityTypeBuilder<T> entity)
|
||||
where T : class, IEntity
|
||||
{
|
||||
entity
|
||||
.HasOne(entity => entity.Entity)
|
||||
.WithOne()
|
||||
.HasForeignKey<T>(entity => entity.Id)
|
||||
.IsRequired();
|
||||
entity.HasOne(e => e.Entity).WithOne().HasForeignKey<T>(e => e.Id).IsRequired();
|
||||
}
|
||||
|
||||
private void BindLocaleString<T>(
|
||||
@@ -144,6 +142,8 @@ public partial class Pf2eDbContext
|
||||
// Keywords
|
||||
modelBuilder.Entity<Keyword>(entity =>
|
||||
{
|
||||
BindLocaleString(entity, k => k.Name);
|
||||
|
||||
entity
|
||||
.HasMany(e => e.Aliases)
|
||||
.WithOne(e => e.Keyword)
|
||||
@@ -483,9 +483,11 @@ public partial class Pf2eDbContext
|
||||
);
|
||||
}
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public static bool LocaleSearch(LocaleString data, string search_value) =>
|
||||
throw new InvalidOperationException("Only for LINQ translation");
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public static bool LocaleSearchArray(LocaleString data, IEnumerable<string> search_values) =>
|
||||
throw new InvalidOperationException("Only for LINQ translation");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user