Intro to MongoDB with C# - Learn what NoSQL is, why it is different than SQL and how to use it in C#

Поделиться
HTML-код
  • Опубликовано: 28 дек 2024

Комментарии • 570

  • @johnconnor9787
    @johnconnor9787 5 лет назад +5

    Video is uploaded 5 minutes ago and someone already clicked a dislike. Hey man, you even did not watch this!!!
    Thank you Tim for this tutorial. Thumb up!

    • @NorbertWebDev
      @NorbertWebDev 5 лет назад

      Lol, dident even remake the dislike, there are some bad people runing round the internet :)))

    • @IAmTimCorey
      @IAmTimCorey  5 лет назад +6

      Yeah, I saw that. The funny thing is that RUclips cares about engagement. The more engagement a video gets (likes, dislikes, comments), the higher they rank it so technically, that person is helping me just a bit. :-)

    • @23myiah
      @23myiah 5 лет назад +1

      Yes, very poor show to dislike without even viewing. Thank you Tim for giving us your time and knowledge.

    • @pylvr8021
      @pylvr8021 5 лет назад +3

      She must be an Ex lol

  • @ben.thornhill
    @ben.thornhill 5 лет назад +9

    Awesome introduction to NoSQL for .NET developers! Thanks as always and best wishes Tim.

  • @Evan-zj5mt
    @Evan-zj5mt 5 лет назад +2

    Dude, your videos are great. Neither rushed nor slow, and including all of the salient information a newbie to a subject needs. Kudos!

  • @codecomposer88
    @codecomposer88 3 года назад +2

    Thank you for a good introduction, Tim. Been using MSSQL for many years and knows it very well. For me this was a first look at NoSQL, and it looks very very interesting! At first it feels very uncomfortable with the loose data structure but it really makes a lot of sense. Just the fact that the termonology is "documents" rather than "tables" makes so much sense; love that we're simply just storing the data as it actually is instead of joining tables and all that.

  • @artemprokhorov506
    @artemprokhorov506 5 лет назад +23

    Hello Tim,
    You have a logical error in this video starting from the time position 1:00:00, when you tried to bring and use new NameModel class. It is working for you because you deleted the last record that has PrimaryAddress just before you introduced NameModel. If you actually have couple existing records in DB, some of them have only FirstName and LastName (and Id for sure) and some have FirstName, LastName and PrimaryAddress, you won't be able to use NameModel as you just did. You will have unhandled exception in the line:
    return collection.Find(new BsonDocument()).ToList();
    saying: 'Element 'PrimaryAddress' does not match any field or property of class MongoDBDemo.NameModel.'
    So you cannot "narrow down" your objects so easily if you actually have additional data in the MongoDB, you will have to use some conversion.

    • @IAmTimCorey
      @IAmTimCorey  5 лет назад +17

      I forgot to show that. Sorry about that. The solution is to put a [BsonIgnoreExtraElements] on the top of your model and it will work. I meant to show it. Thanks for pointing it out.

  • @iamtheone9670
    @iamtheone9670 Год назад +2

    Thank you Tim Corey, you explained that mongoDb is faster than sql perfectly. Have learned something new!

    • @IAmTimCorey
      @IAmTimCorey  Год назад +1

      It can be faster. That doesn't mean it is always the better choice. There are always tradeoffs. I'm glad it was valuable.

  • @RalfsBalodis
    @RalfsBalodis 4 года назад +6

    0:00 - Intro
    1:27 - Setup: Mongo DB Community Server installation
    8:06 - Creating Demo Core Console App
    9:35 - MongoDB NuGet
    11:04 - Mongo CRUD
    12:50 - "Connection string"
    14:50 - Connecting to database
    17:13 - Data storage in MongoDB
    24:39 - Inserting data in database
    28:07 - Changing data set structure
    30:45 - Inserting different data set in the table and benefit of NoSQL
    36:52 - Retrieving data form database
    42:00 - MongoDB Query
    48:40 - Update and delete methods
    54:28 - Insert or Update record
    59:00 - Delete record
    59:42 - Returning different data model from database record
    1:02:55 - Demo code clean up
    1:03:20 - MongoDB when and why?
    1:15:15 - Summary and concluding remarks

  • @DasturlashniOrganamiz
    @DasturlashniOrganamiz 4 года назад +1

    Mr. Corey, thank you. I am accepted to an internship position in an international company called Exadel. The knowledge you are sharing in RUclips is priceless. I am still learning from your content and plan to one your paid courses once I receive my salary as a .net developer.
    Your student from Uzbekistan :)

    • @IAmTimCorey
      @IAmTimCorey  4 года назад

      Awesome! I am glad I was able to be a part of your journey.

  • @xando81
    @xando81 4 года назад +5

    UpsertRecord with the ReplaceOne, 52:39, is obsolete in new Mongo installs. Need to replace "new BsonDocument..." with a filter on the ID
    public void UpsertRecord(string table, Guid id, T record)
    {
    // Create the collection
    var collection = db.GetCollection(table);
    // Create the filter
    var filter = Builders.Filter.Eq("Id", id);
    // Replace the record via an upsert
    // Upsert is an update if the filter finds something or
    // an insert if there is nothing matching
    collection.ReplaceOne(
    filter,
    record,
    new ReplaceOptions { IsUpsert = true });
    }

  • @emirhandemirci6677
    @emirhandemirci6677 4 года назад +1

    Tim Corey Very useful tutorial. Learned all the basics for a NoSql database in just 1 hour. Keep up the good work!

  • @anshulchoure7521
    @anshulchoure7521 4 года назад +1

    I am learning NoSQL for the first time and its the best video have found it very informative and in very understandable tone. MongoDB is very good NoSQL option with .NET Core. Thanks

  • @ohmyohmyohmy2
    @ohmyohmyohmy2 5 лет назад +1

    Another terrifically educational video. Thanks for taking the time to produce and post. Always look forward to your content.

  • @AnalogDave
    @AnalogDave 4 года назад +1

    Thanks for this. It really helped me understand MongoDB and when to use it. I've been using MSSQL for 20 years. I don't see using mongodb for anything at work yet, but I'm testing it with a app at home.

  • @steejayk
    @steejayk 5 лет назад +1

    Your video is NEVER too long!

  • @mirragemelkyr
    @mirragemelkyr 4 года назад +1

    This is a great Video, I've done a introductory course in MongoDB, but as you said it right "this is my new tool... then now what?" even they in that course just tell you about using it with console and Atlas so this is a very good piece of material to integrate it with C# Thanks a lot.

  • @xeyalteyyubov1175
    @xeyalteyyubov1175 2 года назад +1

    Thanks, Tim that is one of the most beautiful no SQL videos on youtube.

  •  4 года назад +1

    Thanks Tim. Very nice introduction to MongoDB and NoSQL world.

  • @georgetuccio6053
    @georgetuccio6053 4 года назад

    As usual, a very, very nice video. Got a project on this noSQL thing and had no idea where to start. Was most-delighted when I saw you did a video because I knew it was going to be the best place to start. Took me through all the CRUD operations and can't believe how simple it is in C#. The Cosmo Db in Azure is a "fake" MongoDb. It offers various "API"s, one of them is Mongo. So, for the most part, you send it normal Mongo instructions and it responds, just like Mongo. Cool. And, only costs about $5-$6 a month to get started. Connection String inserts just like you said it would in your video. I am a SQL Server bigot but am most-happy about being able to add this to my resume and quiver. Yeah, I can see the positives. Did have 2 questions. One, more complex filter usage for query, upsert and delete. Two, can you remove a property in a "document" once added. Not the value of the property but the property itself. Say you added something and company policy has changed and that property, from each record ("document") has to be removed for legal reasons. Also, I'm curious, it's so fast? There has to be indexing then. Is it/are they clustered or non-clustered? Would be very surprised if there were no indexes. I found the constant reference to Models interesting. So non-structured and yet the model usage. Not sure how to wrap my head around that but, coming from a very-structured world, I find this really easy going. Thanks again Tim. All the best. Awesome.

    • @IAmTimCorey
      @IAmTimCorey  4 года назад

      I will be doing other videos shortly using MongoDB. As for removing the property, you should be able to pull down the record and then save it without the property. As for the speed, its speed comes primarily from the fact that all of the data is together instead of pulling from separate locations. One quick note: I originally thought you could drop the units to 100 for MongoDB but you cannot so the smallest database you can get is 400 units, which costs $25/month. Just be careful of that.

  • @FakirCB
    @FakirCB 5 лет назад +1

    Thanks for another great video, Tim. I'd just like to point out that the mongo driver is quite clever and can do lambda expressions within Find() and other methods. So for example things like this are perfectly possible:
    return await db.Find(x => x.UserId == userId)
    .Skip(page * pagesize)
    .Limit(pagesize)
    .ToListAsync();

  • @shrimpsnplants
    @shrimpsnplants 5 лет назад

    "That's the basic structure of MongoDB meaning that isn't really a structure" you made my day :D

  • @alexcyoung
    @alexcyoung 5 лет назад

    Great video Tim! And a nice, simple way of handling CRUD operations without requiring models to inherit from a common 'entity' base class.

    • @IAmTimCorey
      @IAmTimCorey  5 лет назад

      Thanks. I considered a common model base but decided against it for this video.

  • @alvinbernardo9551
    @alvinbernardo9551 4 года назад +2

    For all free tutorial in youtube, this is great

  • @dwain.d
    @dwain.d 5 лет назад

    Thanks Tim. I'm fresh out of a programming qualification and often used your videos to further understand things, and now am currently building my first free lance production application. The application has a requirement for a database so this this video appearing is very timely. My first prototype used SQL but it felt like overkill for the data structure. I have heard a lot about Mongo from current web stacks (MEAN, MERN etc) but didn't realise I could use it from C#. I look forward to trying this out instead and seeing how it goes for my application.

    • @IAmTimCorey
      @IAmTimCorey  5 лет назад

      Excellent. Let us know how it goes.

  • @amirday2daychallenge
    @amirday2daychallenge 5 лет назад +1

    Tq for your short and sweet video about how to use MongoDB in C#, it was handy.

    • @IAmTimCorey
      @IAmTimCorey  5 лет назад +1

      You are most welcome. Thanks for watching.

  • @antonzhernosek5552
    @antonzhernosek5552 2 года назад +1

    Even though I don't like how long the videos are, they're on a whole other level of usefulness compared to any other online tutorial. You're a godsend, Tim

    • @IAmTimCorey
      @IAmTimCorey  2 года назад

      I am glad you find them valuable.

  • @Randomness-rl8lv
    @Randomness-rl8lv 3 года назад +2

    Wow awesome video as always Tim! Since you asked at the end of your video, perhaps you can make a subsequent video explaining / integrating Microsoft Identity with MongoDB!

  • @Dumah79
    @Dumah79 3 месяца назад

    Your explations are best Tim just thank you.

  • @amoljawalkar6273
    @amoljawalkar6273 2 года назад +1

    One of the best tutorial found online. Thank you so much

  • @taha5871
    @taha5871 4 года назад +1

    Awesome video explaining how u use MongoDB with C# , thanks so much 💙💙

  • @umairraza192
    @umairraza192 3 года назад

    Excellent Tutorial ! I like the way you create these these common generic functions so we can directly use them with our models. Thank you very much for your effort and time. Stay blessed .

  • @CaatjuhNL1
    @CaatjuhNL1 4 года назад

    One of the best tutorial I have followed so far! Thank you for your time and effort for making the video. Background explanation was also clear and nice to listen to. Keep it up!

  • @pampula9327
    @pampula9327 5 лет назад +1

    Awesome guide and so easy to follow. Thank you very much Tim!
    I would love to see maybe simple CRUD web app using net core api with MongoDB. That would be really awesome.
    I am hard core beginner in C# and this was so easy to follow.

    • @IAmTimCorey
      @IAmTimCorey  5 лет назад +2

      I'm glad it was so easy to follow. I'll add your suggestion to the list.

  • @xando81
    @xando81 4 года назад +3

    Need to decorate the NameModel a bit in order to get it to work now. 1:01:19
    [BsonIgnoreExtraElementsAttribute]
    public class NameModel
    {
    [BsonId]
    public Guid Id { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
    }

  • @khemo240
    @khemo240 5 лет назад

    Tim you came in clutch with this tutorial....I just started using the database so your intro will be very helpful... I'm from Jamaica so the Grammer may differ from standard English 😅

  • @AhmetYigiter
    @AhmetYigiter 5 лет назад

    I love your videos... My English is max. intermediate but I understood everything because of your great and clean vocalization. Of course thanks for the information too...

  • @rongliao9255
    @rongliao9255 4 года назад

    Great tutorial! NoSQL database can be a great choice for the new projects!

  • @Tiagorockman
    @Tiagorockman 3 года назад

    Top one best video i have seen about mongodb c#. Thanks alot for share!

  • @Randomness-rl8lv
    @Randomness-rl8lv 4 года назад +3

    Hi Tim thank you so much for you video's!! You are a online hero!!
    It would be awesome if you could make video where you integrate .Net Core Identity to a MongoDB back end (like in this video). Thank you so much!!

    • @IAmTimCorey
      @IAmTimCorey  4 года назад +2

      I will add it to the list. Thanks for the suggestion.

  • @T-par-T
    @T-par-T 4 года назад

    Mark my words: Tim is the best!

  • @DamianWalczak
    @DamianWalczak 4 года назад +1

    Thank you Tim that was very informative

  • @zbigniewcwiakalski7253
    @zbigniewcwiakalski7253 6 месяцев назад

    42:55 - if it is db.GetCollection(table) does it mean even though you want to get one single record (by id) does it load whole collection ? Does it fetch the whole table even if I want 1 record from db ?

  • @frozen_dusk579
    @frozen_dusk579 4 года назад

    thank you for explaining it so clearly and calmly

  • @Tajdev
    @Tajdev 3 года назад +2

    Great Video. Please do advance Level video also which covers Aggregation, ACID AND Triggers.

  • @KouroushMetal
    @KouroushMetal 5 лет назад

    Very Good One. Thanks. Big questions are Group, Index, Search Speed On non-Id columns, and datagridview datasource with all these not consistent documents.

  • @jakubondrak1922
    @jakubondrak1922 5 лет назад +1

    Hi Tim, awesome video again. I really like your channel. This was the first time I come across with MongoDB. Do you have or plan another videos about it? I'm planning to create an application and MongoDB look promising. Thanks, Jakub

    • @IAmTimCorey
      @IAmTimCorey  5 лет назад

      I do plan on using it in other videos. It will also be one of the database types in my Foundation in C# module 8 course on data access. That comes out this month.

  • @touseef.awan1
    @touseef.awan1 4 года назад +1

    Thank you Tim. You are best.

  • @andreasbrunnstrom8458
    @andreasbrunnstrom8458 5 лет назад

    I have not gone through the whole video yet but thanks alot. I did not get sql server to install correctly but this works and will get me further along now :)

  • @codecomposer88
    @codecomposer88 3 года назад +3

    Are there equivalents in MongoDB (or NoSQLs in general) to SQL views, stored procedures and triggers? Does it even make any sense to think in these terms when it comes to NoSQL?

    • @IAmTimCorey
      @IAmTimCorey  3 года назад +4

      As far as views and stored procedures, no not really. There doesn't need to be because we treat data differently. We don't focus on relationships, we focus on complete documents. We approach the problem differently, so we end up using different solutions. There can be triggers in a NoSQL database. For instance, an Azure Function can be triggered from a data change event in a CosmosDB database.

    • @codecomposer88
      @codecomposer88 3 года назад

      @@IAmTimCorey Thank you!

  • @matteobarbieri2989
    @matteobarbieri2989 5 лет назад

    great tutorial. I first had some trouble deserializing because of my MongoD release (3.6.5). With version 4 works fine

  • @jaspercoleman3269
    @jaspercoleman3269 3 года назад

    Great video content as always. Thanks for sharing the knowledge, it keeps me motivated to learn more.

  • @Diploidus
    @Diploidus 4 года назад +3

    Hi pls, fix me if I wrong.
    The query "LadAllRecords" occasionally worked for NameModel collection, just because the table didn't contain documents with Address or DOB at this moment.
    Probably you forgot to decorate class NameModel with [BsonIgnoreExtraElements]?

  • @NAIVEBOYANDY
    @NAIVEBOYANDY 4 года назад

    Eye-opening! Thank you, Tim!

  • @ronakpatel6120
    @ronakpatel6120 5 лет назад

    Awesome video. You really make programming simple.

  • @kellysys
    @kellysys 5 лет назад

    It was very helpful to me.
    Thank you Tim.

  • @rachitkohli
    @rachitkohli 3 года назад

    Love the way you explain. Good stuff there!

  • @toshitosliba4737
    @toshitosliba4737 2 года назад +2

    Hello, I started to develop my game like a year and 3 months ago, I am alone doing this, no easy feat let me tell you and I am using Unity. I planned and divided my project in phases, first I would develop the base of the game as single player, then later on I would use the asset Fishnetworking and convert my single player game into a multiplayer. And after I finished converting my systems I hit to a point where I would need a database. For example I have features such as character creation, also I want to make a guild system and a group system. Besides of the other systems, as they need a database as well to save data, so I started to look and found about mongoDB, at first I wanted to go for mySQL, but I saw that NoSQL might be a better fit for my game. And so I started, but to me it's kind overwhelming, because I am just starting on the database field.
    And thank goodness I found your video, it goes to the point and you actually created a helper class to kind interact when I want to manage my database in some way. I am so thankful for that, this video helped me alot :)

  • @cameronroberson5627
    @cameronroberson5627 4 года назад

    Hey Tim Corey, really great video here!
    I had a few questions:
    First, how would we get a Guid in a real world situation? It looks like they are user specific, and in your video you grabbed it from the console if I remember correctly. @46:05
    Is Guid needed for security? Could we just find a user based on UserName?
    Thanks for your video,

    • @IAmTimCorey
      @IAmTimCorey  4 года назад +1

      I am using the developer tools to inspect the objects I have in memory (3 PersonModel objects). Inside of those objects are the GUIDs. So, if you wanted to access that data, you just pull it out of the object (or use the object). No need to involve the developer tools. I was just showing you the values instead of printing them to the Console.
      As for needing the GUID, you use that for easy lookup of the record. You can query by other values, but the GUID will be unique and is indexed.

    • @cameronroberson5627
      @cameronroberson5627 4 года назад +1

      @@IAmTimCorey Great answer. Thanks Tim

  • @rajnikantsolanki8385
    @rajnikantsolanki8385 3 года назад +1

    It is nice video Tim. Thank you.

  • @rc2893
    @rc2893 5 лет назад

    Thanks for the information. Really liked the video.

  • @codeme8016
    @codeme8016 3 года назад +1

    What a wonderful tutorial!

  • @ahmetb3286
    @ahmetb3286 4 года назад

    That is what i am lookin for. Thx for sharing with us

  • @TheJessejunior
    @TheJessejunior 5 лет назад

    Great intro! just cleared my mind!

  • @asadali118
    @asadali118 5 лет назад

    Great thanks, a value able content and much appreciated instructions in the end of the video.

    • @IAmTimCorey
      @IAmTimCorey  5 лет назад +1

      You are most welcome. Thanks for watching.

  • @meriszulic9717
    @meriszulic9717 4 года назад

    Great tutorial as always. Tutorial how and when to use relations in MangoDB may be helpful too. Thanks a lot.

    • @IAmTimCorey
      @IAmTimCorey  4 года назад

      I will add it to the list. Thanks for the suggestion.

  •  5 лет назад +1

    Thank you for this tutorial. It has enlightened me.
    What if there is more then two tables and there are some relations between them? For example a trainings table and an employees and a table that handles for attendees. I think this is for relational databases. Could it even build with mongo db?

    • @IAmTimCorey
      @IAmTimCorey  5 лет назад +1

      Yes it can be built but more likely you would set it up differently. If an employee attends a training session, that training session would be attached to the employee record. No relationship needed.

    • @FakirCB
      @FakirCB 5 лет назад

      Or you can do it the normalized way and add a GUID of some record from another collection, just like a foreign key. But then you have to handle fetching related data manually, Mongo won't do that for you. Altough this is a valid method, once the scheme gets more complex, it can very well turn into a huge mess.

  • @maximecallebaut3949
    @maximecallebaut3949 5 лет назад +1

    Thanks just got an assignment of school about mongo

  • @elad9209
    @elad9209 4 года назад

    hey I just watched the video and it was very helpful especially because there is rarely any approachable materials about mongodb with C#
    it could be amazing to have a playlist tutorial app with mongodb

    • @IAmTimCorey
      @IAmTimCorey  4 года назад

      I will add it to the list. Thanks for the suggestion.

  • @sir.johnbalman9877
    @sir.johnbalman9877 2 года назад +1

    so know this is an old view, but I'm wondering for a structure standpoint it seems that alot of the "child" tables or reference tables that have many to many relations are just consumed by the parent object /document..... is there any case where two document need to be related or do just call the data from document 1 that you need and then add to document 2 for future reads? I hope that was clear but i proable wasn't I contune watching your suggestion app and hope my questions get answered :)

  • @cbirchy87
    @cbirchy87 4 года назад +2

    Hi Tim, It appears the ReplaceOne has been made obsolete. What the is new way of doing the same thing for an Upsert?

    • @nestle579
      @nestle579 3 года назад

      UpdateOptions was replaced by ReplaceOptions. This is my modified implementation:
      public void UpsertRecord(string table, Guid id, T reccord)
      {
      var collection = db.GetCollection(table);
      var result = collection.ReplaceOne(
      new BsonDocument("_id", new BsonBinaryData(id, GuidRepresentation.Standard)),
      reccord,
      new ReplaceOptions { IsUpsert = true });
      }

  • @mrfreddie04p
    @mrfreddie04p 5 лет назад

    1:01:53 Hi, Tim! When I tried to load records into List, I got the following error "'Element 'dob' does not match any field or property of class MongoDBDemo.NameModel.'". So, for me adding just the "id" field did not solve the problem and the system looked for all fields coming from the database to be mapped. I determined that the exception was triggered by ToList() call. Any idea why it behaved differently in my environment?
    [Edit] Just figured it out. Needed to decorate NameModel with [BsonIgnoreExtraElements]. Still interesting that it worked for you. Perhaps the Mongo Driver NuGet package version - I used 2.9.2.

    • @IAmTimCorey
      @IAmTimCorey  5 лет назад

      That's interesting. Not sure why you had that error.

  • @summerbreeze25syria
    @summerbreeze25syria 4 года назад +1

    Thank you very much. At the end, you mentioned when to use MongoDB and you said it has this issue of transactions, would it be suitable to use MongoDB in an online shop application?

    • @IAmTimCorey
      @IAmTimCorey  4 года назад

      Definitely. MongoDB can be used (at this point) anywhere that a relational database (like SQL) can be used. It is different and you have to approach things differently, but MongoDB is fully ACID compliant.

  • @theumairtahir1
    @theumairtahir1 4 года назад

    Very helpful tutorial to start MongoDB with .Net. Can you please make some more tutorials to discuss more details about it?

    • @IAmTimCorey
      @IAmTimCorey  4 года назад +2

      I will add it to the list. Thanks for the suggestion.

  • @NIKOLAOSGYPAS
    @NIKOLAOSGYPAS 11 месяцев назад

    Hello Tim, the video was great! Do you have a video explaining how to implement a transactions in mongo DB?

    • @IAmTimCorey
      @IAmTimCorey  11 месяцев назад +1

      In the Suggestion Site course (playlist here on RUclips), we did transactions when we handled Upvoting suggestions. I don't know the exact video, though.

  • @maxizinsmeister6216
    @maxizinsmeister6216 5 лет назад

    Thanks for the video, very easy to follow along :)

  • @HelmutPolischer
    @HelmutPolischer 3 года назад +4

    The compiler now reports a warning with the line

    new BsonDocument("_id", id)
    BsonValue.implicit operator BsonValue(Guid)' is obsolete: 'Use the BsonBinaryData constructor instead and specify a Guid representation.

    Following this advice, the method becomes the following and compiles without a warning.
    public void UpsertRecord(string table, Guid id, T record)
    {
    var collection = GetCollection(table);
    var filter = new BsonDocument("_id", new BsonBinaryData(id, GuidRepresentation.Standard));
    collection.ReplaceOne(filter, record, new ReplaceOptions { IsUpsert = true });
    }

  • @sepwille7793
    @sepwille7793 4 года назад +1

    Thanks for the very useful tutorial Tim!
    However, i am struggling to retrieve objects who are child of one array object. So i have one object which is an array, in this array are multiple nested objects of different classtypes...
    Do you have an idea how to find the right 'nested objects?

    • @IAmTimCorey
      @IAmTimCorey  4 года назад

      I am not sure I see what the problem is. If you load an object, you will load all of the nested objects inside of it.

    • @johnbond6806
      @johnbond6806 4 года назад

      I have the same issue, I would like to just update a child (Object) of an document, because loading all the children from the document seems a little bit inefficient. The thing is that I can't access the child by using its id, it seems like mongodb tries to search in the parents but doesn't search in the children. Is there a way to search ID in children and update it or search the parent by ID and then update ONLY a certain child?

  • @mahdiasadifard3725
    @mahdiasadifard3725 5 лет назад

    It was great training, thanks Tim

  • @udakara9753
    @udakara9753 4 года назад

    This was really helpful bro. thank you so much

  • @malnadgowda_inusa3734
    @malnadgowda_inusa3734 5 лет назад

    Hey Tim, amazing videos. I live near Scranton PA. 😀

    • @IAmTimCorey
      @IAmTimCorey  5 лет назад

      Awesome! Hey, I'm speaking at Philly Code Camp in October ( phillydotnet.org/2019-2.html ) and TechBash in November ( techbash.com/ ). Both are fairly close to us. Stop by and say hi if you go to either event. I would love to meet you.

    • @malnadgowda_inusa3734
      @malnadgowda_inusa3734 5 лет назад

      IAmTimCorey sure definitely, I actually work in Conshohocken as .Net developer.

  • @pabloarthur3045
    @pabloarthur3045 4 года назад

    This is the best tutorial I see for SQL Relational programmers to an introduction to a Non-SQL database. I am getting a timeout, I do not see on the tutorial where you tell the C# the connection. Is this automatically? How do I check that?

    • @IAmTimCorey
      @IAmTimCorey  4 года назад

      If you are getting a timeout, it probably means your connection string is incorrect. I would check that and verify all of the details are correct for your machine.

  • @ericrook78
    @ericrook78 2 года назад +2

    You actually don't need to include the Id field in the NameModel if you add the BsonIgnoreExtraElements attribute to the NameModel class. You got the error about not having an Id because that attribute was not on the class and all of your records had an Id field. You don't get an error about the PrimaryAddress because none of your records had that.

  • @ryanjade2836
    @ryanjade2836 3 года назад +1

    Tim, thank you so much for making this videos. You have made me a better developer. Does MongoDB have an equivalent of a SQL stored procedure?

    • @IAmTimCorey
      @IAmTimCorey  3 года назад +1

      No, but there isn't a need for one.

  • @zaonpt
    @zaonpt 5 лет назад +1

    Nice vid, more mongo pls!!!

    • @IAmTimCorey
      @IAmTimCorey  5 лет назад +1

      Thanks. More will be coming in the future.

  • @dormelamed5974
    @dormelamed5974 4 года назад +1

    Hi Tim :).
    Great video like always!
    I have two questions:
    1. Every time you do - "var collection = db.GetCollection(table);" - do you bring all the data in the Users collection into the local memory?
    2. Is there a better way today to bring data by id (or another field)?
    all the -
    "var filter = Builders.Filter.Eq("Id", id);"
    and then use it like -
    "collection.Find(filter).First();"
    looks so clumsy and not elegant...
    Thanks man!

    • @IAmTimCorey
      @IAmTimCorey  4 года назад

      No, getting the collection is like opening a connection to that set of documents (that "table"). As for a better way, not really. You create the better way by wrapping that in a method.

  • @dogankartaltepe4141
    @dogankartaltepe4141 4 года назад

    Awesome! Learn, learn, learn. Thanks for all the content! Question: What do you think about the Factory pattern where the concrete classes connect to MongoDb or SQL Server. Would this be non-nonsensical since they are so different?

    • @IAmTimCorey
      @IAmTimCorey  4 года назад

      It is hard to switch from a SQL database to a NoSQL database. The types are just so different.

  • @grampygamer8584
    @grampygamer8584 5 лет назад

    Thank you so much! Loved this!

  • @neilvermeulen5283
    @neilvermeulen5283 5 лет назад +1

    Thank you Tim

  • @yukiobest6004
    @yukiobest6004 5 лет назад

    Hi Tim, I am facing an issue while referring to your MongoDb tutorial, which is from 1:01:10 (create NameModel), I have an existing record that contains my Details object (map with DetailsModel class) in my MongoDb. However, when I just wanted to retrieve Id, FirstName and LastName (referred to your NameModel) in my C# program, it also throws System.FormatException as well. Anyhow, your tutorial video still awesome as always!

    • @IAmTimCorey
      @IAmTimCorey  5 лет назад

      My guess is that you are trying to map a type (string, int, etc.) to the wrong type in your model (so mapping a GUID to an int property).

    • @yukiobest6004
      @yukiobest6004 5 лет назад

      @@IAmTimCorey My Id property in NameModel class is Guid which is same as yours. Lets say i got PrimaryAddress object which is same as your PersonModel. And I have NameModel which I only wanted to retrieve Id, FirstName and LastName. However when I wanted to map into my NameModel, the system throws exception: 'Element 'PrimaryAddress' does not match any field or property of class MongoDbDemo.Program+NameModel.'

    • @yukiobest6004
      @yukiobest6004 5 лет назад +2

      @@IAmTimCorey I have solved by adding [BsonIgnoreExtraElements] :-)

    • @kherona
      @kherona 5 лет назад

      @@yukiobest6004 I just had the same issue, glad you found about the [BsonIgnoreExtraElements]. just used it on the class and it worked.

    • @Phenix25100
      @Phenix25100 4 года назад

      @@yukiobest6004 Thank you so much! I also have that issue 😂

  • @andhikaryoka4149
    @andhikaryoka4149 4 года назад

    very very helpfull tutorial, perfect explain about mongodb database. thank u master

  • @potelflorent
    @potelflorent Год назад

    Hi Tim, thanks for the video, really useful ! I want to log data from a sensor, I wonder if it is better for me to create one document pro session, that contains a list of data that I update everytime I want to add a value, of if I should juste create one collection for one set of measures, and so that every measure + timestamp would be a document. I asked Chat GGT to see, according to it, it would be better to create one document for every single measure (measure + timestamp). Thanks for your help !

    • @IAmTimCorey
      @IAmTimCorey  Год назад +1

      You could make a case for either, but I do think that the most common way to do that would be one document with multiple readings. You are keeping like things together in one object.

    • @potelflorent
      @potelflorent Год назад

      @@IAmTimCorey Thank you for your reply! Indeed it would be easier to get back the values to display them into a chart. My fear was the update function would rewirte the whole List when seeing that the size of the List is different. Anyway, let's try it!

    • @potelflorent
      @potelflorent Год назад

      if someone else want to implement timeseries into mongodb, look at www.mongodb.com/blog/post/building-with-patterns-the-bucket-pattern

  • @yellasrinivasreddy8998
    @yellasrinivasreddy8998 2 года назад +2

    One other advantage you missed was scaling is super simple in noSql Dbs

  • @mohammedyousufirfan633
    @mohammedyousufirfan633 3 года назад +1

    wonderful tutorial!

  • @bjornkreye2211
    @bjornkreye2211 4 года назад +1

    Hi Tim, I have a question to this, how do people hide passwords if they use Atlas for example and the app i avaiable on the internet, people could just refacot it and see the connection string with password. Encryption within the code is also not working since you can just refactor that too. Is there any best practice for that? How do other people safe their data in cloud databases without showing any connectionstring/password in code?

    • @IAmTimCorey
      @IAmTimCorey  3 года назад +1

      If you are running a web app, the connection string will be securely on the server. If you are running a desktop application, that's a problem that cannot be solved through encryption, etc. as you pointed out. The solution is to go through an API like I do in the TimCo Retail Manager series.
      More Info: ruclips.net/video/rFncI9yfY-E/видео.html

    • @bjornkreye2211
      @bjornkreye2211 3 года назад

      @@IAmTimCorey hey thanks for your answer, after I asked I checked pretty much all your Videos. Im half trough the TimCo Retail Manager series Playlist. Thanks for your content, you are doing gods work here ;)

  • @johnbond6806
    @johnbond6806 4 года назад +1

    I see you use [BsonId] for "tagging" the Id so Bson can notice that it is in fact the id. I tried not using it and still worked so, is it strictly necessary or if I don't use may the data base break at some point?

    • @IAmTimCorey
      @IAmTimCorey  4 года назад

      I believe if you use Id then MongoDB assumes. Tagging it makes it clear.

  • @nuthanmurari
    @nuthanmurari 3 года назад +2

    If possible do a video on ACID - Comparison using SQL SERVER and MongoDB using an example.

    • @IAmTimCorey
      @IAmTimCorey  3 года назад

      I will add it to the list. Thanks for the suggestion.

  • @JohnMotamed
    @JohnMotamed 4 года назад

    The default value of Guid in C# is not null, it is empty Guid. Now are you saying that MongoDb checks empty Guid for insert and non empty Guid for update? @24:45

    • @IAmTimCorey
      @IAmTimCorey  4 года назад

      Correct. It checks and identifies that it needs a GUID and creates one.

  • @deicomic720
    @deicomic720 5 лет назад +2

    Got a question on how to do logs using Mongodb. Can you do a tutorial on how to do log with Mongodb?

    • @IAmTimCorey
      @IAmTimCorey  5 лет назад

      You can use it like any other database. I'll see what I can do about showcasing that.

    • @charleswoodruff9013
      @charleswoodruff9013 5 лет назад

      There's a Nuget for Log4Net using MongoDb, but it hasn't been updated for .Net Core or .Net Standard.

  • @rjshukla_vlogs
    @rjshukla_vlogs 3 года назад

    Great explanation in simple way

  • @Lvl9chao
    @Lvl9chao 5 лет назад

    Hi Tim, do you have a video regarding singleton usage in C#? If I were to build a wpf/winform app that uses mongodb, it would make sense to use a singleton for the MongoCRUD class right? That way I can easily use it across all my winform classes?

    • @IAmTimCorey
      @IAmTimCorey  5 лет назад

      The easiest way to utilize a Singleton is to use Dependency Injection. I demo that in a few places, including the TimCo Retail Manager series. In this case, though, I'm not sure that a singleton is the right choice since it stores database information upon instantiation. If you only have one DB then maybe.

  • @idlehands34
    @idlehands34 4 года назад +1

    Thanks a lot, great tutorial :)