private IReadBinding CreateReadBinding(IClientSessionHandle session, ReadPreference readPreference) { if (session.IsInTransaction && readPreference.ReadPreferenceMode != ReadPreferenceMode.Primary) { throw new InvalidOperationException("Read preference in a transaction must be primary."); } return(ChannelPinningHelper.CreateReadBinding(_cluster, session.WrappedCoreSession.Fork(), readPreference)); }
private DisposableBindingBundle <IReadBindingHandle, RetryableReadContext> CreateReadBindingsAndRetryableReadContext(ICluster cluster, ICoreSessionHandle sessionHandle, bool async) { var readPreference = ReadPreference.Primary; var effectiveReadBindings = ChannelPinningHelper.CreateReadBinding(cluster, sessionHandle, readPreference); var retryableReadContext = CreateRetryableReadContext(effectiveReadBindings, async); return(new DisposableBindingBundle <IReadBindingHandle, RetryableReadContext>(effectiveReadBindings, retryableReadContext)); }