Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

BulkWrite c# example mongodb

//update definitions
var filterDefinition = Builders<User>.Filter.Eq(p => p.isBlocked, false);
var updateDefinition = Builders<User>.Update.Set(p => p.isBlocked, true);

public static async Task BulkUpdateManyMongoDb()
    {
        IMongoDatabase db = _client.GetDatabase("sample_blog");
        var userCollection = db.GetCollection<User>("users");

        var listWrites = new List<WriteModel<User>>();

        var filterDefinition = Builders<User>.Filter.Eq(p => p.isBlocked, false);
        var updateDefinition = Builders<User>.Update.Set(p => p.isBlocked, true);

        listWrites.Add(new UpdateManyModel<User>(filterDefinition, updateDefinition));

        await userCollection.BulkWriteAsync(listWrites);
    }
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# system cryptography hash string 
Csharp :: Non-Serialized Fields in unity inspector 
Csharp :: textbox gotfocus wpf 
Csharp :: c# byte + byte is int 
Csharp :: asp.net call controller from another controller 
Csharp :: c# response.contenttype set filename 
Csharp :: add header in action asp.net mvc 
Csharp :: display none asp.net 
Csharp :: play sound in sequence unity 
Csharp :: run in wpf 
Csharp :: page parent wpf 
Csharp :: wpf databinding 
Csharp :: how to call last string from text file C# 
Csharp :: Get replace normal text from word document in C# 
Csharp :: C# Console font 
Csharp :: c# list to observablecollection 
Csharp :: generic interface c# 
Csharp :: c# extension 
Csharp :: How to create a class and objects in C# 
Csharp :: js if empty then 0 
Csharp :: c# sequential struct with fixed array size 
Csharp :: This page contains six pages, created with MigraDoc and scaled down to fit on one page 
Csharp :: C# varible 
Csharp :: wpf fixed window size 
Csharp :: remove loading bars devexpress on callback 
Csharp :: c# fieldnullexception 
Csharp :: how to cut image from timeline editor in c# 
Csharp :: how to system func bool unity 
Csharp :: Include multiple siblings at the Level 
Csharp :: c# check if float value is positif 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =