Skip to content

Commit

Permalink
Store multiple documents with StoreDoc
Browse files Browse the repository at this point in the history
  • Loading branch information
jay-zahiri committed Nov 13, 2024
1 parent 14b468f commit 603cde7
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/Persistence/Wolverine.Marten/IMartenOp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ public static class MartenOps
/// <summary>
/// Return a side effect of storing the specified document in Marten
/// </summary>
/// <param name="document"></param>
/// <param name="documents"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
public static StoreDoc<T> Store<T>(T document) where T : notnull
public static StoreDoc<T> Store<T>(params T[] documents) where T : notnull
{
if (document == null)
if (documents == null)
{
throw new ArgumentNullException(nameof(document));
throw new ArgumentNullException(nameof(documents));
}

return new StoreDoc<T>(document);
return new StoreDoc<T>(documents);
}

/// <summary>
Expand Down Expand Up @@ -224,18 +224,18 @@ public void Execute(IDocumentSession session)
IReadOnlyList<object> IStartStream.Events => Events;
}

public class StoreDoc<T> : DocumentOp where T : notnull
public class StoreDoc<T> : IMartenOp where T : notnull
{
private readonly T _document;
private readonly T[] _documents;

public StoreDoc(T document) : base(document)
public StoreDoc(params T[] documents)
{
_document = document;
_documents = documents;
}

public override void Execute(IDocumentSession session)
public void Execute(IDocumentSession session)
{
session.Store(_document);
session.Store(_documents);
}
}

Expand Down

0 comments on commit 603cde7

Please sign in to comment.