internal IAsyncEnumerable <DocumentSnapshot> StreamAsync(ByteString transactionId, CancellationToken cancellationToken) => StreamResponsesAsync(transactionId, cancellationToken) .Where(resp => resp.Document != null) .Select(resp => DocumentSnapshot.ForDocument(Database, resp.Document, Timestamp.FromProto(resp.ReadTime)));
internal async Task <QuerySnapshot> SnapshotAsync(ByteString transactionId, CancellationToken cancellationToken) { var responses = StreamResponsesAsync(transactionId, cancellationToken); Timestamp?readTime = null; List <DocumentSnapshot> snapshots = new List <DocumentSnapshot>(); await responses.ForEachAsync(response => { if (response.Document != null) { snapshots.Add(DocumentSnapshot.ForDocument(Database, response.Document, Timestamp.FromProto(response.ReadTime))); } if (readTime == null && response.ReadTime != null) { readTime = Timestamp.FromProto(response.ReadTime); } }, cancellationToken).ConfigureAwait(false); GaxPreconditions.CheckState(readTime != null, "The stream returned from RunQuery did not provide a read timestamp."); return(new QuerySnapshot(this, snapshots.AsReadOnly(), readTime.Value)); }
internal static WriteResult FromProto(V1Beta1.WriteResult result, wkt::Timestamp commitTime) { GaxPreconditions.CheckNotNull(result, nameof(result)); GaxPreconditions.CheckNotNull(commitTime, nameof(commitTime)); return(new WriteResult(Timestamp.FromProto(result.UpdateTime ?? commitTime))); }
/// <summary> /// Creates a precondition that the document has the specified last update time. /// </summary> public static Precondition LastUpdated(Timestamp timestamp) => new Precondition(new V1Beta1.Precondition { UpdateTime = timestamp.ToProto() });
private WriteResult(Timestamp updateTime) { UpdateTime = updateTime; }