Couchbase.N1QL.QueryRequest.ConsistentWith C# (CSharp) Method

ConsistentWith() public method

Provides a means of ensuring "read your own writes" or RYOW consistency on the current query.
Note: ScanConsistency will be overwritten to N1QL.ScanConsistency.AtPlus.
public ConsistentWith ( MutationState mutationState ) : IQueryRequest
mutationState MutationState State of the mutation.
return IQueryRequest
        public IQueryRequest ConsistentWith(MutationState mutationState)
        {
#pragma warning disable 618
            ScanConsistency(N1QL.ScanConsistency.AtPlus);
#pragma warning restore 618
            _scanVectors = new Dictionary<string, Dictionary<string, List<object>>>();
            foreach (var token in mutationState)
            {
                Dictionary<string, List<object>> vector;
                if (_scanVectors.TryGetValue(token.BucketRef, out vector))
                {
                    var bucketId = token.VBucketId.ToString();
                    List<object> bucketRef;
                    if (vector.TryGetValue(bucketId, out bucketRef))
                    {
                        if ((long)bucketRef.First() < token.SequenceNumber)
                        {
                            vector[bucketId] = new List<object>
                            {
                                token.SequenceNumber,
                                token.VBucketUUID.ToString()
                            };
                        }
                    }
                    else
                    {
                        vector.Add(token.VBucketId.ToString(),
                            new List<object>
                            {
                                token.SequenceNumber,
                                token.VBucketUUID.ToString()
                            });
                    }
                }
                else
                {
                    _scanVectors.Add(token.BucketRef, new Dictionary<string, List<object>>
                    {
                        {
                            token.VBucketId.ToString(),
                            new List<object>
                            {
                                token.SequenceNumber,
                                token.VBucketUUID.ToString()
                            }
                        }
                    });
                }
            }
            return this;
        }