Skip to content

Commit 2d6bdee

Browse files
committed
Add an implicit conversion from an object array
1 parent bdceec2 commit 2d6bdee

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/SqlParameterCollection.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ public SqlParameter this[string name] {
3030
}
3131
}
3232

33+
/// <summary>
34+
/// Creates a new parameter collection from the specified array of positional parameters.
35+
/// </summary>
36+
/// <param name="parameters">The array whose elements are copied to the parameter collection.</param>
37+
/// <returns>The parameter collection corresponding to the specified array of positional parameters.</returns>
38+
public static implicit operator SqlParameterCollection(object?[] parameters) => [.. parameters.Select((value, index) =>
39+
value is SqlParameter parameter ? parameter : new SqlParameter($"?{index + 1}", value)
40+
)];
41+
3342
/// <summary>
3443
/// Creates a new parameter collection from the specified list of positional parameters.
3544
/// </summary>

0 commit comments

Comments
 (0)