[#79] Entities: Remove EF proxies
This commit is contained in:
@@ -106,21 +106,21 @@ 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 => PartFilter == null ? Parts : Parts.Where(p => PartFilter(p));
|
||||
|
||||
[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 +153,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,13 +27,15 @@ namespace Elwig.Models.Entities {
|
||||
public virtual ICollection<WbGem> Gems { get; private set; } = null!;
|
||||
|
||||
[InverseProperty(nameof(Parent))]
|
||||
public virtual ICollection<WineOrigin> Children { get; private set; } = null!;
|
||||
public virtual ICollection<WineOrigin> RealChildren { get; private set; } = null!;
|
||||
[NotMapped]
|
||||
public List<WineOrigin> Children { get; private set; } = [];
|
||||
|
||||
public int Level => (Parent?.Level + 1) ?? 0;
|
||||
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user