Table of Contents

Method SetOnInsert

Namespace
MongoDB.Driver.Builders
Assembly
MongoDB.Driver.Legacy.dll

SetOnInsert<TMember>(Expression<Func<TDocument, TMember>>, TMember)

Sets the value of the named element to the specified value only when an insert occurs as part of an upsert operation (see $setOnInsert).

public UpdateBuilder<TDocument> SetOnInsert<TMember>(Expression<Func<TDocument, TMember>> memberExpression, TMember value)

Parameters

memberExpression Expression<Func<TDocument, TMember>>

The member expression.

value TMember

The new value.

Returns

UpdateBuilder<TDocument>

The builder (so method calls can be chained).

Type Parameters

TMember

The type of the member.