You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Document(StorageType = StorageType.Json, Prefixes = new[] { "Lobby" })]
public class Lobby : BaseGuidEntity
{
[Indexed]
public GameType GameType { get; set; }
[Indexed(CascadeDepth = 1)]
public List<Player> Players { get; set; } = new List<Player>();
}
public class BaseGuidEntity : IEntity<Guid>
{
[RedisIdField]
[Indexed]
public Guid Id { get; set; }
[Indexed]
public DateTime CreationDate { get; set; }
public BaseGuidEntity()
{
Id = Guid.NewGuid();
CreationDate = DateTime.Now;
}
}
public class Player:BaseGuidEntity
{
[Indexed]
public long UserId { get; set; }
[Indexed]
public string? UserName { get; set; }
[Indexed]
public string? ConnectionId { get; set; }
[Indexed]
public int Order { get; set; }
}
Steps to reproduce:
Create the model of lobby with 1 player
Add 1 more player to the Players List and update model with UpdateAsync
public async Task<Lobby> Join(JoinLobbyViewModel model)
{
Lobby lobby = (await _lobbyRepository.GetByAsync(x => x.Id.Equals(Guid.Parse(model.GameId)))).FirstOrDefault();
if (lobby == null)
{
throw new Exception("Game is not found");
}
Player player = new Player() { ConnectionId = model.ConnectionId, UserId = model.UserId, Order = lobby.Players.Count - 1, UserName = model.UserName };
lobby.Players.Add(player);
await _lobbyRepository.UpdateAsync(lobby);
return lobby;
}
Actual result:
3 Players presented in the Players List. After any update Player list duplicating himself with adding entity additional.
Expected result:
2 Players presented in Players List. After each update Player list not duplicating himself and adding new single entity.
It works fine with
_repo = (RedisCollection)provider.RedisCollection(false)
instead of
_repo =(RedisCollection)provider.RedisCollection()
The text was updated successfully, but these errors were encountered:
Hi @htmlpk - looks like the issue here is that when Redis OM is building the diff, it is not accounting for the fact that the CreationDate is converted to a number in Redis (hence it's adding the extra record). Work around for now would be to set saveState to false when initializing _lobbyRepository, that will prevent it from preforming the diff.
Versions:
.Net 7
Redis OM 0.5.2
Model:
Steps to reproduce:
Actual result:
3 Players presented in the Players List. After any update Player list duplicating himself with adding entity additional.
Expected result:
2 Players presented in Players List. After each update Player list not duplicating himself and adding new single entity.
It works fine with
_repo = (RedisCollection)provider.RedisCollection(false)
instead of
_repo =(RedisCollection)provider.RedisCollection()
The text was updated successfully, but these errors were encountered: