-
Type: New Feature
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: API, Session Management
-
None
Current SessionApi is simple, but not fit to developer requirements.
When i need use session across many repositories - it need to pass IClientSessionHandle to each repository method. But repository interface is domain contract and we need some ambient implementation.
This api must be optional without any incomatibility to other driver api
Example:
public interface IUserRepository { Task<User> Create(IClientSessionHandle sessionHandle, User user); } public interface IRolesRepository { Task AssignRoles(IClientSessionHandle sessionHandle, string login, List<Roles> roles); }
It is not usefull and clear
We want to see something like this:
public interface IUserRepository { Task<User> Create(User user); //clear } public interface IRolesRepository { Task AssignRoles(string login, List<Roles> roles); //clear } public class AccountService : IAccountService { private readonly IUserRepository _userRepository; private readonly IRolesRepository _rolesRepository; private readonly ISessionFactory _sessionFactory; public AccountService(IUserRepository userRepository, IRolesRepository rolesRepository, ISessionFactory sessionFactory) { _userRepository = userRepository; _rolesRepository = rolesRepository; _sessionFactory = sessionFactory; } public async Task CreateUser(UserModel user) { using (_sessionFactory.Create()) //session factory can contain our abstraction { //operation auto join to current session like TransactionScope in ADO.NET await _userRepository.Create(user); await _rolesRepository.AssignRoles(user.login, roles); } } }
- duplicates
-
CSHARP-2890 TransactionScope support for MongoDB
- Backlog
- is related to
-
CSHARP-2021 Implement Drivers Sessions API
- Closed