Hi i use C# driver for mongodb .
How can i create default session to avoid writing an ‘if else’ condition ?
What now
if(!session)
return _x.FindOneAndUpdate<x>(c => c.UserId == userId && c.f== f, u, new
FindOneAndUpdateOptions<x>
{
IsUpsert = true,
ReturnDocument = ReturnDocument.After
});
else
return _x.FindOneAndUpdate<x>(session, c => c.UserId == userId && c.f== f, u, new FindOneAndUpdateOptions<x>
{
IsUpsert = true,
ReturnDocument = ReturnDocument.After
});
for example so
_x.FindOneAndUpdate<x>(session ?? Session.Default(),