Skip to content

Commit 5ff82b4

Browse files
committed
Added MartenOp.StoreObjects
1 parent ccb1940 commit 5ff82b4

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/Persistence/Wolverine.Marten/IMartenOp.cs

+28
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,22 @@ public static StoreManyDocs<T> StoreMany<T>(params T[] documents) where T : notn
5555
return new StoreManyDocs<T>(documents);
5656
}
5757

58+
/// <summary>
59+
/// Return a side effect of storing an enumerable of potentially mixed documents in Marten
60+
/// </summary>
61+
/// <param name="documents"></param>
62+
/// <returns></returns>
63+
/// <exception cref="ArgumentNullException"></exception>
64+
public static StoreObjects StoreObjects(params object[] documents)
65+
{
66+
if (documents == null)
67+
{
68+
throw new ArgumentNullException(nameof(documents));
69+
}
70+
71+
return new StoreObjects(documents);
72+
}
73+
5874
/// <summary>
5975
/// Return a side effect of inserting the specified document in Marten
6076
/// </summary>
@@ -273,6 +289,18 @@ public override void Execute(IDocumentSession session)
273289
}
274290
}
275291

292+
public class StoreObjects : DocumentsOp
293+
{
294+
public StoreObjects(params object[] documents) : base(documents) { }
295+
296+
public StoreObjects(IList<object> documents) : this(documents.ToArray()) { }
297+
298+
public override void Execute(IDocumentSession session)
299+
{
300+
session.StoreObjects(Documents);
301+
}
302+
}
303+
276304
public class InsertDoc<T> : DocumentOp where T : notnull
277305
{
278306
private readonly T _document;

0 commit comments

Comments
 (0)