コード例 #1
0
 /// <summary>
 /// Retrieves a document from the Azure Search index.
 /// <see href="https://msdn.microsoft.com/library/azure/dn798929.aspx"/>
 /// </summary>
 /// <param name='operations'>
 /// Reference to the Microsoft.Azure.Search.IDocumentOperations.
 /// </param>
 /// <param name="key">
 /// The key of the document to retrieve; See
 /// <see href="https://msdn.microsoft.com/library/azure/dn857353.aspx"/> for the rules for constructing valid
 /// document keys.
 /// </param>
 /// <param name="selectedFields">
 /// List of field names to retrieve for the document; Any field not retrieved will be missing from the
 /// returned document.
 /// </param>
 /// <returns>
 /// Response containing the document.
 /// </returns>
 /// <remarks>
 /// The non-generic overloads of the Get and GetAsync methods make a best-effort attempt to map JSON types in
 /// the response payload to .NET types. See
 /// <see cref="IDocumentOperations.GetAsync(string, IEnumerable&lt;string&gt;, CancellationToken)"/>
 /// for more information.
 /// </remarks>
 public static Task <DocumentGetResponse> GetAsync(
     this IDocumentOperations operations,
     string key,
     IEnumerable <string> selectedFields)
 {
     return(operations.GetAsync(key, selectedFields, CancellationToken.None));
 }
コード例 #2
0
 public override async Task ApplyAsync(IDocumentOperations operations, IReadOnlyList <StreamAction> streams,
                                       CancellationToken cancellation)
 {
     foreach (var stream in streams)
     {
         foreach (var @event in stream.Events)
         {
             try
             {
                 await ApplyEvent(operations, stream, @event, cancellation);
             }
             catch (MartenCommandException)
             {
                 throw;
             }
             catch (NpgsqlException)
             {
                 throw;
             }
             catch (Exception e)
             {
                 throw new ApplyEventException(@event, e);
             }
         }
     }
 }
 /// <summary>
 /// Searches for documents in the Azure Search index.  (see
 /// <see href="https://msdn.microsoft.com/library/azure/dn798927.aspx"/> for more information)
 /// </summary>
 /// <typeparam name="T">
 /// The CLR type that maps to the index schema. Instances of this type can be retrieved as documents
 /// from the index.
 /// </typeparam>
 /// <param name='operations'>
 /// Reference to the Microsoft.Azure.Search.IDocumentOperations.
 /// </param>
 /// <param name="searchText">
 /// A full-text search query expression; See
 /// <see href="https://msdn.microsoft.com/library/azure/dn798920.aspx"/> for more information about search
 /// query syntax.
 /// </param>
 /// <param name="searchParameters">
 /// Parameters to further refine the search query.
 /// </param>
 /// <returns>
 /// Response containing the documents matching the query.
 /// </returns>
 /// <remarks>
 /// The generic overloads of the Search and SearchAsync methods support mapping of Azure Search field types to
 /// .NET types via the type parameter T. See
 /// <see cref="IDocumentOperations.GetAsync&lt;T&gt;(string, System.Collections.Generic.IEnumerable&lt;string&gt;, CancellationToken)"/>
 /// for more details on the type mapping.
 /// </remarks>
 public static Task <DocumentSearchResponse <T> > SearchAsync <T>(
     this IDocumentOperations operations,
     string searchText,
     SearchParameters searchParameters) where T : class
 {
     return(operations.SearchAsync <T>(searchText, searchParameters, CancellationToken.None));
 }
コード例 #4
0
 /// <summary>
 /// Initializes a new instance of the SearchIndexClient class.
 /// </summary>
 private SearchIndexClient()
     : base()
 {
     this._documents         = new DocumentOperations(this);
     this._apiVersion        = "2015-02-28";
     this.HttpClient.Timeout = TimeSpan.FromSeconds(300);
 }
コード例 #5
0
        public async Task ApplyAsync(IDocumentOperations operations, IReadOnlyList <StreamAction> streams,
                                     CancellationToken cancellation)
        {
            // Doing the filtering here to prevent unnecessary network round trips by allowing
            // an aggregate projection to "work" on a stream with no matching events
            var filteredStreams = streams
                                  .Where(x => Projection.AppliesTo(x.Events.Select(x => x.EventType)))
                                  .ToArray();

            var slices = await Slicer.SliceInlineActions(operations, filteredStreams, Tenancy).ConfigureAwait(false);

            var martenSession = (DocumentSessionBase)operations;

            foreach (var slice in slices)
            {
                IStorageOperation?operation;

                if (Projection.MatchesAnyDeleteType(slice))
                {
                    operation = Storage.DeleteForId(slice.Id, slice.Tenant);
                }
                else
                {
                    operation = await DetermineOperation(martenSession, slice, cancellation).ConfigureAwait(false);
                }

                if (operation != null)
                {
                    operations.QueueOperation(operation);
                }
            }
        }
コード例 #6
0
        public async Task Project(Event3 e, IDocumentOperations ops)
        {
            var lookup = await ops.LoadAsync <Lookup>(e.LookupId);

            // now use the lookup document and the event to carry
            // out other document operations against the ops parameter
        }
 /// <summary>
 /// Suggests query terms based on input text and matching documents in the Azure Search index.  (see
 /// <see href="https://msdn.microsoft.com/library/azure/dn798936.aspx"/> for more information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the Microsoft.Azure.Search.IDocumentOperations.
 /// </param>
 /// <param name="searchText">
 /// The search text on which to base suggestions.
 /// </param>
 /// <param name="suggesterName">
 /// The name of the suggester as specified in the suggesters collection that's part of the index definition.
 /// </param>
 /// <returns>
 /// Response containing the suggested text and documents matching the query.
 /// </returns>
 /// <remarks>
 /// The non-generic overloads of the Suggest and SuggestAsync methods make a best-effort attempt to map JSON
 /// types in the response payload to .NET types. See
 /// <see cref="IDocumentOperations.GetAsync(string, System.Collections.Generic.IEnumerable&lt;string&gt;, CancellationToken)"/>
 /// for more information.
 /// </remarks>
 public static DocumentSuggestResponse Suggest(
     this IDocumentOperations operations,
     string searchText,
     string suggesterName)
 {
     return(operations.Suggest(searchText, suggesterName, new SuggestParameters()));
 }
        public void Project(NewOutflowRecorded @event, IDocumentOperations operations)
        {
            var issue = operations.Load <AllAccountsSummaryView>(Guid.Empty) ?? new AllAccountsSummaryView();

            issue.Apply(@event);
            operations.Store(issue);
        }
 /// <summary>
 /// Suggests query terms based on input text and matching documents in the Azure Search index.  (see
 /// <see href="https://msdn.microsoft.com/library/azure/dn798936.aspx"/> for more information)
 /// </summary>
 /// <typeparam name="T">
 /// The CLR type that maps to the index schema. Instances of this type can be retrieved as documents
 /// from the index.
 /// </typeparam>
 /// <param name='operations'>
 /// Reference to the Microsoft.Azure.Search.IDocumentOperations.
 /// </param>
 /// <param name="searchText">
 /// The search text on which to base suggestions.
 /// </param>
 /// <param name="suggesterName">
 /// The name of the suggester as specified in the suggesters collection that's part of the index definition.
 /// </param>
 /// <returns>
 /// Response containing the suggested text and documents matching the query.
 /// </returns>
 /// <remarks>
 /// The generic overloads of the Suggest and SuggestAsync methods support mapping of Azure Search field types
 /// to .NET types via the type parameter T. See
 /// <see cref="IDocumentOperations.GetAsync&lt;T&gt;(string, System.Collections.Generic.IEnumerable&lt;string&gt;, CancellationToken)"/>
 /// for more details on the type mapping.
 /// </remarks>
 public static Task <DocumentSuggestResponse <T> > SuggestAsync <T>(
     this IDocumentOperations operations,
     string searchText,
     string suggesterName) where T : class
 {
     return(operations.SuggestAsync <T>(searchText, suggesterName, new SuggestParameters()));
 }
コード例 #10
0
ファイル: error_handling.cs プロジェクト: tonykaralis/marten
 public void Project(IEvent <Travel> e, IDocumentOperations operations)
 {
     foreach (var thrower in _throwers)
     {
         thrower.Process(e);
     }
 }
コード例 #11
0
 public override void Apply(IDocumentOperations operations, IReadOnlyList <StreamAction> streams)
 {
     foreach (var stream in streams)
     {
         foreach (var @event in stream.Events)
         {
             try
             {
                 ApplyEvent(operations, stream, @event);
             }
             catch (NpgsqlException)
             {
                 throw;
             }
             catch (MartenCommandException)
             {
                 throw;
             }
             catch (Exception ex)
             {
                 throw new ApplyEventException(@event, ex);
             }
         }
     }
 }
コード例 #12
0
ファイル: AsyncOptions.cs プロジェクト: tonykaralis/marten
 internal void Teardown(IDocumentOperations operations)
 {
     foreach (var action in _actions)
     {
         action(operations);
     }
 }
コード例 #13
0
 public async Task ApplyAsync(IDocumentOperations operations, IReadOnlyList <StreamAction> streams, CancellationToken cancellation)
 {
     foreach (var stream in streams)
     {
         var events = stream.Events.Select(e => new EventEnvelope(stream.Id, e.Id, e.Version, e.Sequence, e.Data)).ToList().AsReadOnly();
         await _projectionRepository.ApplyEventsAsync(events).ConfigureAwait(false);
     }
 }
コード例 #14
0
 /// <summary>
 /// Queries the number of documents in the Azure Search index.  (see
 /// https://msdn.microsoft.com/library/azure/dn798924.aspx for more
 /// information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the Microsoft.Azure.Search.IDocumentOperations.
 /// </param>
 /// <returns>
 /// Response containing the count of documents in the index.
 /// </returns>
 public static DocumentCountResponse Count(this IDocumentOperations operations)
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((IDocumentOperations)s).CountAsync();
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
 /// <summary>
 /// Suggests query terms based on input text and matching documents in the Azure Search index.  (see
 /// <see href="https://msdn.microsoft.com/library/azure/dn798936.aspx"/> for more information)
 /// </summary>
 /// <typeparam name="T">
 /// The CLR type that maps to the index schema. Instances of this type can be retrieved as documents
 /// from the index.
 /// </typeparam>
 /// <param name='operations'>
 /// Reference to the Microsoft.Azure.Search.IDocumentOperations.
 /// </param>
 /// <param name="searchText">
 /// The search text on which to base suggestions.
 /// </param>
 /// <param name="suggesterName">
 /// The name of the suggester as specified in the suggesters collection that's part of the index definition.
 /// </param>
 /// <param name="suggestParameters">
 /// Parameters to further refine the suggestion query.
 /// </param>
 /// <returns>
 /// Response containing the suggested text and documents matching the query.
 /// </returns>
 /// <remarks>
 /// The generic overloads of the Suggest and SuggestAsync methods support mapping of Azure Search field types
 /// to .NET types via the type parameter T. See
 /// <see cref="IDocumentOperations.GetAsync&lt;T&gt;(string, System.Collections.Generic.IEnumerable&lt;string&gt;, CancellationToken)"/>
 /// for more details on the type mapping.
 /// </remarks>
 public static Task <DocumentSuggestResponse <T> > SuggestAsync <T>(
     this IDocumentOperations operations,
     string searchText,
     string suggesterName,
     SuggestParameters suggestParameters) where T : class
 {
     return(operations.SuggestAsync <T>(searchText, suggesterName, suggestParameters, CancellationToken.None));
 }
コード例 #16
0
 /// <summary>
 /// Sends a batch of upload, merge, and/or delete actions to the Azure Search index.  (see
 /// <see href="https://msdn.microsoft.com/library/azure/dn798935.aspx"/> for more information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the Microsoft.Azure.Search.IDocumentOperations.
 /// </param>
 /// <param name="batch">
 /// The batch of index actions.
 /// </param>
 /// <exception cref="IndexBatchException">
 /// Thrown when some of the indexing actions failed, but other actions succeeded and modified the state of
 /// the index. This can happen when the Search Service is under heavy indexing load. It is important to
 /// explicitly catch this exception and check its
 /// <c cref="IndexBatchException.IndexResponse">IndexResponse</c> property. This property reports the status
 /// of each indexing action in the batch, making it possible to determine the state of the index after a
 /// partial failure.
 /// </exception>
 /// <returns>
 /// Response containing the status of operations for all actions in the batch.
 /// </returns>
 public static DocumentIndexResponse Index(this IDocumentOperations operations, IndexBatch batch)
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((IDocumentOperations)s).IndexAsync(batch);
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
コード例 #17
0
 public void Apply(IDocumentOperations operations, IReadOnlyList <StreamAction> streams)
 {
     foreach (var stream in streams)
     {
         var events = stream.Events.Select(e => new EventEnvelope(stream.Id, e.Id, e.Version, e.Sequence, e.Data)).ToList().AsReadOnly();
         _projectionRepository.ApplyEvents(events);
     }
 }
コード例 #18
0
 /// <summary>
 /// Retrieves a document from the Azure Search index.
 /// <see href="https://msdn.microsoft.com/library/azure/dn798929.aspx"/>
 /// </summary>
 /// <typeparam name="T">
 /// The CLR type that maps to the index schema. Instances of this type can be retrieved as documents
 /// from the index.
 /// </typeparam>
 /// <param name='operations'>
 /// Reference to the Microsoft.Azure.Search.IDocumentOperations.
 /// </param>
 /// <param name="key">
 /// The key of the document to retrieve; See
 /// <see href="https://msdn.microsoft.com/library/azure/dn857353.aspx"/> for the rules for constructing valid
 /// document keys.
 /// </param>
 /// <returns>
 /// Response containing the document.
 /// </returns>
 /// <remarks>
 /// The generic overloads of the Get and GetAsync methods support mapping of Azure Search field types to .NET
 /// types via the type parameter T. See
 /// <see cref="IDocumentOperations.GetAsync&lt;T&gt;(string, IEnumerable&lt;string&gt;, CancellationToken)"/>
 /// for more details on the type mapping.
 /// </remarks>
 public static DocumentGetResponse <T> Get <T>(this IDocumentOperations operations, string key)
     where T : class
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((IDocumentOperations)s).GetAsync <T>(key);
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
コード例 #19
0
 /// <summary>
 /// Initializes a new instance of the SearchIndexClient class.
 /// </summary>
 /// <param name='httpClient'>
 /// The Http client
 /// </param>
 public SearchIndexClient(HttpClient httpClient)
     : base(httpClient)
 {
     this._documents  = new DocumentOperations(this);
     this._apiVersion = "2015-02-28";
     this._longRunningOperationInitialTimeout = -1;
     this._longRunningOperationRetryTimeout   = -1;
     this.HttpClient.Timeout = TimeSpan.FromSeconds(300);
 }
コード例 #20
0
 public override void Apply(IDocumentOperations operations, IReadOnlyList <StreamAction> streams)
 {
     foreach (var stream in streams)
     {
         foreach (var @event in stream.Events)
         {
             ApplyEvent(operations, stream, @event);
         }
     }
 }
 /// <summary>
 /// Retrieves the next page of search results from the Azure Search index.  (see
 /// <see href="https://msdn.microsoft.com/library/azure/dn798927.aspx"/> for more information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the Microsoft.Azure.Search.IDocumentOperations.
 /// </param>
 /// <param name="continuationToken">
 /// Encapsulates the state required to fetch the next page of search results from the index.
 /// </param>
 /// <returns>
 /// Response containing the documents matching the query.
 /// </returns>
 /// <remarks>
 /// The non-generic overloads of the ContinueSearch and ContinueSearchAsync methods make a best-effort attempt
 /// to map JSON types in the response payload to .NET types. See
 /// <see cref="IDocumentOperations.GetAsync(string, System.Collections.Generic.IEnumerable&lt;string&gt;, CancellationToken)"/>
 /// for more information.
 /// </remarks>
 public static DocumentSearchResponse ContinueSearch(
     this IDocumentOperations operations,
     SearchContinuationToken continuationToken)
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((IDocumentOperations)s).ContinueSearchAsync(continuationToken);
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
コード例 #22
0
 public override async Task ApplyAsync(IDocumentOperations operations, IReadOnlyList <StreamAction> streams,
                                       CancellationToken cancellation)
 {
     foreach (var stream in streams)
     {
         foreach (var @event in stream.Events)
         {
             await ApplyEvent(operations, stream, @event, cancellation);
         }
     }
 }
コード例 #23
0
 /// <summary>
 /// Retrieves a document from the Azure Search index.
 /// <see href="https://msdn.microsoft.com/library/azure/dn798929.aspx"/>
 /// </summary>
 /// <param name='operations'>
 /// Reference to the Microsoft.Azure.Search.IDocumentOperations.
 /// </param>
 /// <param name="key">
 /// The key of the document to retrieve; See
 /// <see href="https://msdn.microsoft.com/library/azure/dn857353.aspx"/> for the rules for constructing valid
 /// document keys.
 /// </param>
 /// <param name="selectedFields">
 /// List of field names to retrieve for the document; Any field not retrieved will be missing from the
 /// returned document.
 /// </param>
 /// <returns>
 /// Response containing the document.
 /// </returns>
 /// <remarks>
 /// The non-generic overloads of the Get and GetAsync methods make a best-effort attempt to map JSON types in
 /// the response payload to .NET types. See
 /// <see cref="IDocumentOperations.GetAsync(string, IEnumerable&lt;string&gt;, CancellationToken)"/>
 /// for more information.
 /// </remarks>
 public static DocumentGetResponse Get(
     this IDocumentOperations operations,
     string key,
     IEnumerable <string> selectedFields)
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((IDocumentOperations)s).GetAsync(key, selectedFields);
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
 /// <summary>
 /// Searches for documents in the Azure Search index.  (see
 /// <see href="https://msdn.microsoft.com/library/azure/dn798927.aspx"/> for more information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the Microsoft.Azure.Search.IDocumentOperations.
 /// </param>
 /// <param name="searchText">
 /// A full-text search query expression; See
 /// <see href="https://msdn.microsoft.com/library/azure/dn798920.aspx"/> for more information about search
 /// query syntax.
 /// </param>
 /// <param name="searchParameters">
 /// Parameters to further refine the search query.
 /// </param>
 /// <returns>
 /// Response containing the documents matching the query.
 /// </returns>
 /// <remarks>
 /// The non-generic overloads of the Search and SearchAsync methods make a best-effort attempt to map JSON
 /// types in the response payload to .NET types. See
 /// <see cref="IDocumentOperations.GetAsync(string, System.Collections.Generic.IEnumerable&lt;string&gt;, CancellationToken)"/>
 /// for more information.
 /// </remarks>
 public static DocumentSearchResponse Search(
     this IDocumentOperations operations,
     string searchText,
     SearchParameters searchParameters)
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((IDocumentOperations)s).SearchAsync(searchText, searchParameters);
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
コード例 #25
0
 internal static void EnsureTransformsExist(this IDocumentOperations operations)
 {
     try
     {
         operations.As <DocumentSessionBase>().Tenant.EnsureStorageExists(typeof(TransformSchema));
     }
     catch (InvalidDocumentException)
     {
         throw new InvalidOperationException(
                   $"Attempting to use a PLV8/Javascript related feature, but the support is not active in this DocumentStore. Did you forget to call {nameof(StoreOptions)}.{nameof(StoreOptionsExtensions.UseJavascriptTransformsAndPatching)}()?");
     }
 }
 /// <summary>
 /// Suggests query terms based on input text and matching documents in the Azure Search index.  (see
 /// <see href="https://msdn.microsoft.com/library/azure/dn798936.aspx"/> for more information)
 /// </summary>
 /// <typeparam name="T">
 /// The CLR type that maps to the index schema. Instances of this type can be retrieved as documents
 /// from the index.
 /// </typeparam>
 /// <param name='operations'>
 /// Reference to the Microsoft.Azure.Search.IDocumentOperations.
 /// </param>
 /// <param name="searchText">
 /// The search text on which to base suggestions.
 /// </param>
 /// <param name="suggesterName">
 /// The name of the suggester as specified in the suggesters collection that's part of the index definition.
 /// </param>
 /// <param name="suggestParameters">
 /// Parameters to further refine the suggestion query.
 /// </param>
 /// <returns>
 /// Response containing the suggested text and documents matching the query.
 /// </returns>
 /// <remarks>
 /// The generic overloads of the Suggest and SuggestAsync methods support mapping of Azure Search field types
 /// to .NET types via the type parameter T. See
 /// <see cref="IDocumentOperations.GetAsync&lt;T&gt;(string, System.Collections.Generic.IEnumerable&lt;string&gt;, CancellationToken)"/>
 /// for more details on the type mapping.
 /// </remarks>
 public static DocumentSuggestResponse <T> Suggest <T>(
     this IDocumentOperations operations,
     string searchText,
     string suggesterName,
     SuggestParameters suggestParameters)
     where T : class
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((IDocumentOperations)s).SuggestAsync <T>(searchText, suggesterName, suggestParameters);
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
コード例 #27
0
        async Task IProjection.ApplyAsync(IDocumentOperations operations, IReadOnlyList <StreamAction> streams, CancellationToken cancellation)
        {
            var slices = await Slicer.SliceInlineActions(operations, streams).ConfigureAwait(false);

            var martenSession = (DocumentSessionBase)operations;

            await martenSession.Database.EnsureStorageExistsAsync(typeof(TDoc), cancellation).ConfigureAwait(false);

            var storage = (IDocumentStorage <TDoc, TId>)martenSession.StorageFor <TDoc>();

            foreach (var slice in slices)
            {
                slice.Aggregate = await storage.LoadAsync(slice.Id, martenSession, cancellation).ConfigureAwait(false);
                await ApplyChangesAsync(martenSession, slice, cancellation).ConfigureAwait(false);
            }
        }
コード例 #28
0
            public void Apply(IDocumentOperations operations, IReadOnlyList <StreamAction> streams)
            {
                var questEvents = streams.SelectMany(x => x.Events).OrderBy(s => s.Sequence).Select(s => s.Data);

                foreach (var @event in questEvents)
                {
                    if (@event is Quest quest)
                    {
                        operations.Store(new QuestPatchTestProjection {
                            Id = quest.Id
                        });
                    }
                    else if (@event is QuestStarted started)
                    {
                        operations.Patch <QuestPatchTestProjection>(started.Id).Set(x => x.Name, "New Name");
                    }
                }
            }
コード例 #29
0
 public override void Apply(IDocumentOperations operations, IReadOnlyList <StreamAction> streams)
 {
     foreach (var @event in streams.SelectMany(x => x.Events))
     {
         switch (@event.Data)
         {
         case IEvent <Travel> e:
             var travel   = e.Data;
             var distance = new Distance
             {
                 Id    = e.Id,
                 Day   = travel.Day,
                 Total = travel.TotalDistance()
             };
             operations.Store(distance);
             break;
         }
     }
 }
コード例 #30
0
        public async Task ApplyAsync(IDocumentOperations operations, IReadOnlyList <StreamAction> streams,
                                     CancellationToken cancellation)
        {
            // Doing the filtering here to prevent unnecessary network round trips by allowing
            // an aggregate projection to "work" on a stream with no matching events
            var filteredStreams = streams
                                  .Where(x => Projection.AppliesTo(x.Events.Select(x => x.EventType)))
                                  .ToArray();

            var slices = await Slicer.SliceInlineActions(operations, filteredStreams).ConfigureAwait(false);

            var martenSession = (DocumentSessionBase)operations;

            await martenSession.Database.EnsureStorageExistsAsync(typeof(TDoc), cancellation).ConfigureAwait(false);

            foreach (var slice in slices)
            {
                await ApplyChangesAsync(martenSession, slice, cancellation).ConfigureAwait(false);
            }
        }