[WIP] Models/Entities: Remove EF proxies
Some checks failed
Test / Run tests (push) Failing after 2m45s

This commit is contained in:
2026-04-01 16:24:03 +02:00
parent bb1dd3e4e9
commit e983ef918d
30 changed files with 428 additions and 251 deletions

View File

@@ -106,21 +106,18 @@ namespace Elwig.Models.Entities {
[InverseProperty(nameof(DeliveryPart.Delivery))]
public virtual ICollection<DeliveryPart> Parts { get; private set; } = null!;
[NotMapped]
public IEnumerable<DeliveryPart> FilteredParts => PartFilter == null ? Parts : Parts.Where(p => PartFilter(p));
public IEnumerable<DeliveryPart> FilteredParts { get; set; } = [];
[NotMapped]
public Predicate<DeliveryPart>? PartFilter { get; set; }
public int Weight => Parts.Select(p => p.Weight).Sum();
public int FilteredWeight => FilteredParts.Select(p => p.Weight).Sum();
public int Weight => Parts.Sum(p => p.Weight);
public int FilteredWeight => FilteredParts.Sum(p => p.Weight);
public IEnumerable<RawVaribute> Vaributes => Parts
.GroupBy(p => (p.SortId, p.AttrId, p.CultId))
.OrderByDescending(g => g.Select(p => p.Weight).Sum())
.OrderByDescending(g => g.Sum(p => p.Weight))
.Select(g => new RawVaribute(g.Key.SortId, g.Key.AttrId, g.Key.CultId));
public IEnumerable<RawVaribute> FilteredVaributes => FilteredParts
.GroupBy(p => (p.SortId, p.AttrId, p.CultId))
.OrderByDescending(g => g.Select(p => p.Weight).Sum())
.OrderByDescending(g => g.Sum(p => p.Weight))
.Select(g => new RawVaribute(g.Key.SortId, g.Key.AttrId, g.Key.CultId));
public string VaributeString => string.Join(", ", Vaributes);
public string FilteredVaributeString => string.Join(", ", FilteredVaributes);
@@ -153,7 +150,7 @@ namespace Elwig.Models.Entities {
Member.Name, Member.MiddleName, Member.GivenName, Member.BillingAddress?.FullName,
Comment
}.ToList();
list.AddRange(Parts.Select(p => p.Comment).Distinct());
list.AddRange(FilteredParts.Select(p => p.Comment).Distinct());
return Utils.GetSearchScore(list, keywords);
}
}

View File

@@ -184,7 +184,7 @@ namespace Elwig.Models.Entities {
public virtual ICollection<DeliveryPartModifier> PartModifiers { get; private set; } = null!;
[NotMapped]
public IEnumerable<Modifier> Modifiers => PartModifiers.Select(m => m.Modifier).OrderBy(m => m.Ordering);
public IEnumerable<Modifier> Modifiers => []; // PartModifiers.Select(m => m.Modifier).OrderBy(m => m.Ordering);
[InverseProperty(nameof(PaymentDeliveryPart.DeliveryPart))]
public virtual PaymentDeliveryPart? Payment { get; private set; }

View File

@@ -33,7 +33,7 @@ namespace Elwig.Models.Entities {
public string HkIdLevel => $"{new string(' ', Level * 2)}{HkId}";
public int TotalChildNum => 1 + Children.Select(c => c.TotalChildNum).Sum();
public int TotalChildNum => 1 + Children.Sum(c => c.TotalChildNum);
private int SortKey1 => (Parent?.SortKey1 ?? 0) | (TotalChildNum << ((3 - Level) * 8));
public int SortKey => SortKey1 | ((Level < 3) ? (-1 >>> (Level * 8 + 8)) : 0);