diff --git a/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/Shop.cs b/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/Shop.cs index 3c8ffdb..2a5b6ae 100644 --- a/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/Shop.cs +++ b/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/Shop.cs @@ -4,6 +4,7 @@ using SCHALE.Common.Database.ModelExtensions; using SCHALE.Common.NetworkProtocol; using SCHALE.Common.Utils; using SCHALE.GameServer.Services; +using SCHALE.GameServer.Utils; namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers { @@ -280,6 +281,8 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers _context.SaveChanges(); transaction.Commit(); + + _context.Entry(account).Collection(x => x.Items).Reload(); } catch (Exception ex) { diff --git a/SCHALE.GameServer/Services/SharedDataCacheService.cs b/SCHALE.GameServer/Services/SharedDataCacheService.cs index 6adf832..6d03aab 100644 --- a/SCHALE.GameServer/Services/SharedDataCacheService.cs +++ b/SCHALE.GameServer/Services/SharedDataCacheService.cs @@ -1,5 +1,5 @@ -using SCHALE.Common.Extensions; -using SCHALE.Common.FlatData; +using SCHALE.Common.FlatData; +using SCHALE.Common.Utils; namespace SCHALE.GameServer.Services { diff --git a/SCHALE.GameServer/Utils/CollectionEntryExt.cs b/SCHALE.GameServer/Utils/CollectionEntryExt.cs new file mode 100644 index 0000000..a6db85e --- /dev/null +++ b/SCHALE.GameServer/Utils/CollectionEntryExt.cs @@ -0,0 +1,20 @@ +using Microsoft.EntityFrameworkCore.ChangeTracking; + +namespace SCHALE.GameServer.Utils; + +public static class CollectionEntryExt +{ + public static void Reload(this CollectionEntry source) + { + if (source.CurrentValue != null) + { + foreach (var item in source.CurrentValue) + { + source.EntityEntry.Context.Entry(item).State = Microsoft.EntityFrameworkCore.EntityState.Detached; + } + source.CurrentValue = null; + source.IsLoaded = false; + source.Load(); + } + } +} \ No newline at end of file