コード例 #1
0
 public async Task StoreAsync(IDocumentRecord documentRecord)
 {
     await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
         async () =>
         {
             await ResilientSessionContainer.EstablishSessionAsync();
             await ResilientSessionContainer.ResilientSession.UpsertFlattenedDocumentAsync(documentRecord);
         },
         async (ex) => ResilientSessionContainer.HandleCassandraException<Task>(ex));
 }
        public async Task <bool> UpsertFlattenedDocumentAsync(IDocumentRecord documentRecord,
                                                              CancellationToken cancellationToken = default(CancellationToken))
        {
            try
            {
                var list = new List <IDocumentRecord> {
                    documentRecord
                };
                return(await UpsertManyFlattenedDocumentAsync(list, cancellationToken));
            }
            catch (Exception e)
            {
// only here to catch during a debug unit test.
                throw;
            }
        }
        public async Task <IDocumentRecord> FindFlattenedDocumentByTypeAndVersionAsync(string type, string version,
                                                                                       CancellationToken cancellationToken = default(CancellationToken))
        {
            try
            {
                var     session = CassandraSession;
                IMapper mapper  = new Mapper(session);
                cancellationToken.ThrowIfCancellationRequested();
                var record =
                    await
                    mapper.SingleAsync <DocumentRecord>(FindFlattenedDocumentByTypeAndVersion, type, version);

                IDocumentRecord ch = record;
                return(ch);
            }
            catch (Exception e)
            {
// throws an exception when nothing is found,
// Indication of missing element is only in the message, which can't be trusted to be stable.
// need to file a defect against datastax to get better exception information
                return(null);
            }
        }