forked from Raphael/SCHALE.GameServer
fix account items not updated
This commit is contained in:
parent
b20b695f11
commit
11c035d083
|
@ -4,6 +4,7 @@ using SCHALE.Common.Database.ModelExtensions;
|
||||||
using SCHALE.Common.NetworkProtocol;
|
using SCHALE.Common.NetworkProtocol;
|
||||||
using SCHALE.Common.Utils;
|
using SCHALE.Common.Utils;
|
||||||
using SCHALE.GameServer.Services;
|
using SCHALE.GameServer.Services;
|
||||||
|
using SCHALE.GameServer.Utils;
|
||||||
|
|
||||||
namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
|
namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
|
||||||
{
|
{
|
||||||
|
@ -280,6 +281,8 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
|
||||||
_context.SaveChanges();
|
_context.SaveChanges();
|
||||||
|
|
||||||
transaction.Commit();
|
transaction.Commit();
|
||||||
|
|
||||||
|
_context.Entry(account).Collection(x => x.Items).Reload();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
using SCHALE.Common.Extensions;
|
using SCHALE.Common.FlatData;
|
||||||
using SCHALE.Common.FlatData;
|
using SCHALE.Common.Utils;
|
||||||
|
|
||||||
namespace SCHALE.GameServer.Services
|
namespace SCHALE.GameServer.Services
|
||||||
{
|
{
|
||||||
|
|
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue