From 91b35a91ce14969ae277a646b99c84d0eecb0db7 Mon Sep 17 00:00:00 2001 From: sven-n Date: Fri, 27 Oct 2023 19:12:33 +0200 Subject: [PATCH] Delete object when removing an item from an owning parent --- src/Web/AdminPanel/Components/Form/ItemTable.razor.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Web/AdminPanel/Components/Form/ItemTable.razor.cs b/src/Web/AdminPanel/Components/Form/ItemTable.razor.cs index 0eb777338..11676c88e 100644 --- a/src/Web/AdminPanel/Components/Form/ItemTable.razor.cs +++ b/src/Web/AdminPanel/Components/Form/ItemTable.razor.cs @@ -5,8 +5,11 @@ namespace MUnique.OpenMU.Web.AdminPanel.Components.Form; using System.Diagnostics.CodeAnalysis; +using System.Linq.Expressions; +using System.Reflection; using Blazored.Modal; using Microsoft.AspNetCore.Components; +using MUnique.OpenMU.DataModel.Composition; using MUnique.OpenMU.Persistence; /// @@ -105,9 +108,8 @@ private async Task OnRemoveClickAsync(TItem item) { this.Value?.Remove(item); - // use the MemberOfAggregateAttribute here! - if (!this.ValueExpression!.GetAccessedMemberType().IsConfigurationType() - && !typeof(TItem).IsConfigurationType()) + if (this.ValueExpression?.Body is MemberExpression { Member: PropertyInfo propertyInfo } + && propertyInfo.GetCustomAttribute() is not null) { await this.PersistenceContext.DeleteAsync(item).ConfigureAwait(false); }