Join us Sept 17 at .local NYC! Use code WEB50 to save 50% on tickets. Learn more >
MongoDB Event
Docs Menu
Docs Home
/ / /
C#/ .NET 드라이버
/

여러 문서를 삽입합니다.

동기 InsertMany() 메서드 또는 비동기 InsertManyAsync() 메서드를 사용하여 컬렉션에 단일 문서를 삽입할 수 있습니다.

다음은 restaurants 컬렉션에 새 문서를 삽입하는 예시입니다.

Asynchronous 또는 Synchronous 탭을 선택하여 해당 코드를 확인합니다.

// Generates 5 new restaurants by using a helper method
var restaurants = GenerateDocuments();
// Asynchronously inserts the new documents into the restaurants collection
await _restaurantsCollection.InsertManyAsync(restaurants);

작업의 완전히 실행 가능한 예시 는 InsertManyAsync InsertManyAsync() 코드 샘플 참조하세요.

// Generates 5 new restaurants by using a helper method
var restaurants = GenerateDocuments();
// Inserts the new documents into the restaurants collection
_restaurantsCollection.InsertMany(restaurants);

작업의 완전히 실행 가능한 예시 는 InsertMany InsertMany() 코드 샘플 참조하세요.

위의 전체 예시 중 하나를 실행한 후 출력은 다음과 같습니다.

Number of restaurants found before insert: 0
Inserting documents...
Number of restaurants inserted: 5

빌더 사용에 학습 보려면 빌더 를 사용한작업을 참조하세요.

돌아가기

문서 삽입

이 페이지의 내용