Skip to content

Commit 5ee4b82

Browse files
committed
CSHARP-687: changed signature of Combine methods to take an IMongoUpdate instead of an UpdateBuilder.
1 parent d1fcdf2 commit 5ee4b82

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

MongoDB.Driver/Builders/UpdateBuilder.cs

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,10 @@ public static UpdateBuilder BitwiseOr(string name, long value)
161161
/// </summary>
162162
/// <param name="updates">The UpdateBuilders to combine.</param>
163163
/// <returns>A combined UpdateBuilder.</returns>
164-
public static UpdateBuilder Combine(IEnumerable<UpdateBuilder> updates)
164+
public static UpdateBuilder Combine(IEnumerable<IMongoUpdate> updates)
165165
{
166166
if (updates == null) { throw new ArgumentNullException("updates"); }
167+
167168
var combined = new UpdateBuilder();
168169
foreach (var update in updates)
169170
{
@@ -177,9 +178,9 @@ public static UpdateBuilder Combine(IEnumerable<UpdateBuilder> updates)
177178
/// </summary>
178179
/// <param name="updates">The UpdateBuilders to combine.</param>
179180
/// <returns>A combined UpdateBuilder.</returns>
180-
public static UpdateBuilder Combine(params UpdateBuilder[] updates)
181+
public static UpdateBuilder Combine(params IMongoUpdate[] updates)
181182
{
182-
return Combine((IEnumerable<UpdateBuilder>)updates);
183+
return Combine((IEnumerable<IMongoUpdate>)updates);
183184
}
184185

185186
/// <summary>
@@ -800,12 +801,15 @@ public UpdateBuilder BitwiseOr(string name, long value)
800801
/// <summary>
801802
/// Combines another UpdateBuilder into this one.
802803
/// </summary>
803-
/// <param name="otherUpdateBuilder">The UpdateBuilder to combine into this one.</param>
804+
/// <param name="other">The IMongoUpdate to combine into this one.</param>
804805
/// <returns>A combined UpdateBuilder.</returns>
805-
public UpdateBuilder Combine(UpdateBuilder otherUpdateBuilder)
806+
public UpdateBuilder Combine(IMongoUpdate other)
806807
{
807-
if (otherUpdateBuilder == null) { throw new ArgumentNullException("otherUpdateBuilder"); }
808-
foreach (var otherOperation in otherUpdateBuilder.Document)
808+
if (other == null) { throw new ArgumentNullException("other"); }
809+
810+
var otherUpdate = other.ToBsonDocument();
811+
812+
foreach (var otherOperation in otherUpdate)
809813
{
810814
var otherOperationName = otherOperation.Name;
811815
var otherTargets = otherOperation.Value.AsBsonDocument;
@@ -1604,7 +1608,7 @@ public static UpdateBuilder<TDocument> BitwiseOr(Expression<Func<TDocument, long
16041608
/// <returns>
16051609
/// A combined UpdateBuilder.
16061610
/// </returns>
1607-
public static UpdateBuilder<TDocument> Combine(IEnumerable<UpdateBuilder<TDocument>> updates)
1611+
public static UpdateBuilder<TDocument> Combine(IEnumerable<IMongoUpdate> updates)
16081612
{
16091613
if (updates == null) { throw new ArgumentNullException("updates"); }
16101614
var combined = new UpdateBuilder<TDocument>();
@@ -1618,13 +1622,13 @@ public static UpdateBuilder<TDocument> Combine(IEnumerable<UpdateBuilder<TDocume
16181622
/// <summary>
16191623
/// Combines several UpdateBuilders into a single UpdateBuilder.
16201624
/// </summary>
1621-
/// <param name="updates">The UpdateBuilders to combine.</param>
1625+
/// <param name="updates">The updates to combine.</param>
16221626
/// <returns>
16231627
/// A combined UpdateBuilder.
16241628
/// </returns>
1625-
public static UpdateBuilder<TDocument> Combine(params UpdateBuilder<TDocument>[] updates)
1629+
public static UpdateBuilder<TDocument> Combine(params IMongoUpdate[] updates)
16261630
{
1627-
return Combine((IEnumerable<UpdateBuilder<TDocument>>)updates);
1631+
return Combine((IEnumerable<IMongoUpdate>)updates);
16281632
}
16291633

16301634
/// <summary>
@@ -2013,11 +2017,11 @@ public UpdateBuilder<TDocument> BitwiseOr(Expression<Func<TDocument, long>> memb
20132017
/// <summary>
20142018
/// Combines another UpdateBuilder into this one.
20152019
/// </summary>
2016-
/// <param name="otherUpdateBuilder">The UpdateBuilder to combine into this one.</param>
2020+
/// <param name="other">The UpdateBuilder to combine into this one.</param>
20172021
/// <returns>A combined UpdateBuilder.</returns>
2018-
public UpdateBuilder<TDocument> Combine(UpdateBuilder<TDocument> otherUpdateBuilder)
2022+
public UpdateBuilder<TDocument> Combine(IMongoUpdate other)
20192023
{
2020-
_updateBuilder = _updateBuilder.Combine(otherUpdateBuilder._updateBuilder);
2024+
_updateBuilder = _updateBuilder.Combine(other);
20212025
return this;
20222026
}
20232027

0 commit comments

Comments
 (0)