Skip to content

Commit

Permalink
Delete object when removing an item from an owning parent
Browse files Browse the repository at this point in the history
  • Loading branch information
sven-n committed Oct 27, 2023
1 parent 2211ee6 commit 91b35a9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Web/AdminPanel/Components/Form/ItemTable.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/// <summary>
Expand Down Expand Up @@ -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<MemberOfAggregateAttribute>() is not null)
{
await this.PersistenceContext.DeleteAsync(item).ConfigureAwait(false);
}
Expand Down

0 comments on commit 91b35a9

Please sign in to comment.