-
Couldn't load subscription status.
- Fork 3.3k
Open
Description
What problem are you trying to solve?
When working with azure cosmos db in the context of a user, the session token is required for read your own write guarantees (or session consistency) to work.
https://learn.microsoft.com/en-us/azure/cosmos-db/consistency-levels#session-consistency
I could not find any documentation on setting or retrieving the session token in a dbcontext.
Describe the solution you'd like
Possibly you could define extension methods (or extension members when those are released) on the DbContext type to get and set the session token on the DbContext before any reads or writes.
myDbContext.SetSessionToken(sessionToken);
var result = await myDbContext.Documents.Where(x => x.Id == id).FirstOrDefaultAsync();
result.Property = "changes";
await myDbContext.SaveChangesAsync();
sessionToken = myDbContext.GetSessionToken();