LoadAsync immediately after SaveChangesAsync returns null #3433
-
Hi there, app.MapPost("todo/new", async (CreateTodoRequest request, IDocumentSession session) =>
{
var id = Guid.NewGuid();
var @event = new TodoCreated(id, request.Text, request.DueDate);
session.Events.StartStream<Todo>(@event);
await session.SaveChangesAsync();
return await session.LoadAsync<Todo>(id);
}).WithName("Create Todo"); The What am I missing? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
I also tried to change |
Beta Was this translation helpful? Give feedback.
-
@thomaslevesque I figured out the issue, change |
Beta Was this translation helpful? Give feedback.
@thomaslevesque I figured out the issue, change
session.Events.StartStream<Todo>(@event);
tosession.Events.StartStream<Todo>(id, @event);
. Essentially, we are setting the stream Id same as the Todo Id otherwise the stream will generate it's own Id which will reflect as the Todo Id in the projected document.