Dot net core REST APIs with MongoDb full build

Поділитися
Вставка
  • Опубліковано 16 гру 2024

КОМЕНТАРІ • 14

  • @momspaghetti1911
    @momspaghetti1911 Рік тому +1

    Isn’t the mongodb client supposed to be a singleton and not transient

    • @ravindradevrani
      @ravindradevrani  Рік тому +1

      Yes.. mongo db client should be singleton according Microsoft docs.
      Sorry about that.

    • @raymohmoud2282
      @raymohmoud2282 4 місяці тому

      Password already in connection string you have to get it from MongoDb network users page and paste it

  • @alkmyalcn3275
    @alkmyalcn3275 8 місяців тому

    Thanks for Tutorial first of all, your video is really good for beginners.
    For 6:14 -> I think with C# 8 there is null! equalization referance for properties, which is much better for best practice. If you mark prop as nullable with " ? " operator, it may cause leak problems beacuse it makes you able pass null for that prop. Otherwise " null! " referance makes prop " nullable but cannot be null " . And I think for this example " CategoryName " property is one of MUST HAVE props. That means we should give it a name which means cannot pass it null in any scenario. Correct me if I'm wrong please. :)

    • @ravindradevrani
      @ravindradevrani  8 місяців тому

      Sorry,I haven't heard about null!. I never understood why they have adde ? In a string property. It wasn't alwys like this.
      We always put the [required] validation in a model property. So there wont be a problem of null value insertion to database.

  • @pilgrimk
    @pilgrimk 6 місяців тому

    great video, VERY informative! thank you!

  • @IsDBdR_
    @IsDBdR_ 7 місяців тому

    your videos are so helpful. Please create a project video using MudBlazor and MongoDB

  • @kranthithadakapally2289
    @kranthithadakapally2289 Рік тому

    How to authenticate Connection Strings of mongoDB like we do for MySQL or SqlServer by using UserId and Password?

  • @ArthunMorgan747
    @ArthunMorgan747 Рік тому

    bro you have predefined schema but in my case I have random data I want to store in mongodb any suggestions?

    • @phongnguyenphamthanh3106
      @phongnguyenphamthanh3106 Рік тому

      just allocate ImongoCollection and BsonDocument, then you can add to your database directly, here's my simple code:
      MongoClient client = new MongoClient(connectionString);
      IMongoDatabase database = client.GetDatabase(databaseName);
      // Get a reference to the collection
      IMongoCollection collection = database.GetCollection("products");
      // Create a new document
      BsonDocument newProduct = new BsonDocument
      {
      { "Name", "Sample Product" },
      { "Price", 19.99 },
      { "Category", "Electronics" }
      };
      // Insert the document
      collection.InsertOne(newProduct);
      Console.WriteLine("Document inserted.");
      Check out IMongoCollection class for other methods to add to database

  • @MTSightseeing
    @MTSightseeing Рік тому

    How to upload images using dotnet core api sql server

    • @ravindradevrani
      @ravindradevrani  Рік тому

      You can follow this, ua-cam.com/video/bFbCAJCxxHI/v-deo.html

  • @sairamsagar649
    @sairamsagar649 Рік тому

    at 33:11 minutes you didn't create a mongodb Database. how did u insert it ?. @ravindradevarani

    • @ravindradevrani
      @ravindradevrani  Рік тому

      It will be created automatically, if you provide correct connection string and every setting related to it.