InsertOne mongodb in .net core does not return result

omid mirzaei

i am new in mongodb And when i use InsertOne Or InsertMany methods does not return any result. how can i be sure data were inserted. I Use MongoDB.Driver Version 2.10.3 Sorry for my language

mickl

You can check the implementation here.

Basically whenever something goes wrong like there's a connection errror or your insert violates unique key you will get a MongoWriteException. So your code may look like this:

try
{
    collection.InsertOne(document);
}
catch (MongoWriteException e)
{
    Console.WriteLine(e.Message);
}

There's another method in MongoDB - bulkWrite - which might execute some operations successfully and fail for the other ones. In such case MongoDB .NET driver returns an instance of BulkWriteResult<TDocument> class.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

.net core string operator does not execute with the excepted result

分類Dev

MongoDB + .NET Core 1.0?

分類Dev

How to return a 304 result from ASP.NET Core web api?

分類Dev

.Net Core Async File Result

分類Dev

how to group in mongoDB and return all fields in result

分類Dev

Why does Asp.Net Core 2.1 WebApi return a 500.19 error?

分類Dev

Why does compactMap return a nil result?

分類Dev

Why does my program return inaccurate result?

分類Dev

Why does `{} + []` return a different result from `a = {} + []` in Javascript?

分類Dev

Mongodb lookup aggregation does not return relational data

分類Dev

Same code gives different result in .net core and .net 4.7.2

分類Dev

.NET Core API view model return

分類Dev

Why does search for matching value in multi dimensional array not return a result?

分類Dev

changing the sub-string delimiter in a regex, does not return same result

分類Dev

Does .NET Core work with the NUnit console runner?

分類Dev

Why does the mongodb aggregate $avg code return all of the documents ungrouped?

分類Dev

The current .NET SDK does not support targeting .NET Core 2.1.3

分類Dev

Azure ServiceBus message from .net core does not parse in .net 4.6.1

分類Dev

Return "raw" json in ASP.NET Core 2.0 Web Api

分類Dev

How to return 403 Forbidden response as IActionResult in ASP.NET Core

分類Dev

ASP.NET Core return JSON with status code

分類Dev

How to return 403 Forbidden response as IActionResult in ASP.NET Core

分類Dev

How to return 403 Forbidden response as IActionResult in ASP.NET Core

分類Dev

Return string from Web API .NET Core get operation

分類Dev

ASP.NET Core - The name 'JsonRequestBehavior' does not exist in the current context

分類Dev

ASP.NET Core - The name 'JsonRequestBehavior' does not exist in the current context

分類Dev

What does the win/any runtime mean in .NET Core

分類Dev

What does the win/any runtime mean in .NET Core

分類Dev

What does the win/any runtime mean in .NET Core

Related 関連記事

  1. 1

    .net core string operator does not execute with the excepted result

  2. 2

    MongoDB + .NET Core 1.0?

  3. 3

    How to return a 304 result from ASP.NET Core web api?

  4. 4

    .Net Core Async File Result

  5. 5

    how to group in mongoDB and return all fields in result

  6. 6

    Why does Asp.Net Core 2.1 WebApi return a 500.19 error?

  7. 7

    Why does compactMap return a nil result?

  8. 8

    Why does my program return inaccurate result?

  9. 9

    Why does `{} + []` return a different result from `a = {} + []` in Javascript?

  10. 10

    Mongodb lookup aggregation does not return relational data

  11. 11

    Same code gives different result in .net core and .net 4.7.2

  12. 12

    .NET Core API view model return

  13. 13

    Why does search for matching value in multi dimensional array not return a result?

  14. 14

    changing the sub-string delimiter in a regex, does not return same result

  15. 15

    Does .NET Core work with the NUnit console runner?

  16. 16

    Why does the mongodb aggregate $avg code return all of the documents ungrouped?

  17. 17

    The current .NET SDK does not support targeting .NET Core 2.1.3

  18. 18

    Azure ServiceBus message from .net core does not parse in .net 4.6.1

  19. 19

    Return "raw" json in ASP.NET Core 2.0 Web Api

  20. 20

    How to return 403 Forbidden response as IActionResult in ASP.NET Core

  21. 21

    ASP.NET Core return JSON with status code

  22. 22

    How to return 403 Forbidden response as IActionResult in ASP.NET Core

  23. 23

    How to return 403 Forbidden response as IActionResult in ASP.NET Core

  24. 24

    Return string from Web API .NET Core get operation

  25. 25

    ASP.NET Core - The name 'JsonRequestBehavior' does not exist in the current context

  26. 26

    ASP.NET Core - The name 'JsonRequestBehavior' does not exist in the current context

  27. 27

    What does the win/any runtime mean in .NET Core

  28. 28

    What does the win/any runtime mean in .NET Core

  29. 29

    What does the win/any runtime mean in .NET Core

ホットタグ

アーカイブ