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!
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. :-)
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.
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 :)
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
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
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.
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.
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
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.
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.
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!
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.
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.
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!
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();
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 .
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.
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...
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.
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!!
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 😅
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; } }
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 }); }
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 :)
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
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.
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 :)
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 }); }
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]?
Very Good One. Thanks. Big questions are Group, Index, Search Speed On non-Id columns, and datagridview datasource with all these not consistent documents.
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.
UTC - "The official abbreviation for Coordinated Universal Time is UTC. It came about as a compromise between English and French speakers. Coordinated Universal Time in English would normally be abbreviated CUT. Temps Universel Coordonné in French would normally be abbreviated TUC."
In Cluj, Romania, Banca Transilvania Atm-s used to crash several times a day when somebody tried to deposit cash in his account. The Atm swallowed the cash, but did not put it into the depositors account. I learned to don't ever put money into an Atm, when my money got swallowed on a Friday evening, and I was going to leave the country for 3 weeks on the next day.
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?
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.
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!
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.
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
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?
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.
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.
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 }); }
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 :)
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.
I noticed that sometimes you use "_id" for the filter and sometimes "Id". I guess that using Id still works because of the BsonId decorator. If that is the case, wouldn't it be safer to always use "_id" to allow the MongoCrud to be generic and always work with whatever model you are mapping?
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!
Lol, dident even remake the dislike, there are some bad people runing round the internet :)))
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. :-)
Yes, very poor show to dislike without even viewing. Thank you Tim for giving us your time and knowledge.
She must be an Ex lol
Awesome introduction to NoSQL for .NET developers! Thanks as always and best wishes Tim.
Thank you!
Dude, your videos are great. Neither rushed nor slow, and including all of the salient information a newbie to a subject needs. Kudos!
Thank you!
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.
Glad it was helpful!
Thank you Tim Corey, you explained that mongoDb is faster than sql perfectly. Have learned something new!
It can be faster. That doesn't mean it is always the better choice. There are always tradeoffs. I'm glad it was valuable.
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 :)
Awesome! I am glad I was able to be a part of your journey.
Tim Corey Very useful tutorial. Learned all the basics for a NoSql database in just 1 hour. Keep up the good work!
Glad it was helpful!
Another terrifically educational video. Thanks for taking the time to produce and post. Always look forward to your content.
You are welcome.
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
Thank you!
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
Glad it was helpful!
Thanks, Tim that is one of the most beautiful no SQL videos on youtube.
Thank you!
Your video is NEVER too long!
Thanks!
Thanks Tim. Very nice introduction to MongoDB and NoSQL world.
Glad it was helpful!
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.
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.
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
I am glad you find them valuable.
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.
Glad it was helpful!
Awesome video explaining how u use MongoDB with C# , thanks so much 💙💙
You're very welcome!
Tq for your short and sweet video about how to use MongoDB in C#, it was handy.
You are most welcome. Thanks for watching.
"That's the basic structure of MongoDB meaning that isn't really a structure" you made my day :D
I'm glad you enjoyed it.
Great video Tim! And a nice, simple way of handling CRUD operations without requiring models to inherit from a common 'entity' base class.
Thanks. I considered a common model base but decided against it for this video.
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.
Glad it was helpful!
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!
We appreciate the suggestion and I have added it to Tim's list.
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.
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.
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!
You're very welcome!
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();
Awesome! Thanks for sharing.
One of the best tutorial found online. Thank you so much
Your endorsement is much appreciated! Thank you for helping to spread the word.
For all free tutorial in youtube, this is great
Thank you!
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 .
You're very welcome!
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.
I'm glad it was so easy to follow. I'll add your suggestion to the list.
Top one best video i have seen about mongodb c#. Thanks alot for share!
His goal is to make learning easier. It appears he is doing just that!
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...
Awesome!
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.
Excellent. Let us know how it goes.
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!!
I will add it to the list. Thanks for the suggestion.
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 😅
Excellent!
Thank you Tim. You are best.
You are very welcome
Mark my words: Tim is the best!
Thanks!
Great tutorial! NoSQL database can be a great choice for the new projects!
Thanks!
Thank you Tim that was very informative
You are welcome.
Great Video. Please do advance Level video also which covers Aggregation, ACID AND Triggers.
We appreciate the suggestion and I have added it to Tim's list.
Great video content as always. Thanks for sharing the knowledge, it keeps me motivated to learn more.
You are welcome.
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; }
}
Thanks for sharing.
thank you for explaining it so clearly and calmly
Glad it was helpful!
great tutorial. I first had some trouble deserializing because of my MongoD release (3.6.5). With version 4 works fine
Glad you got it figured out.
Love the way you explain. Good stuff there!
Thanks!
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 });
}
Thanks for sharing.
Thanks a lot.
It was very helpful to me.
Thank you Tim.
You are welcome.
Eye-opening! Thank you, Tim!
You are welcome.
Awesome video. You really make programming simple.
Thank you!
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 :)
You are welcome.
What a wonderful tutorial!
Thanks!
Great thanks, a value able content and much appreciated instructions in the end of the video.
You are most welcome. Thanks for watching.
That is what i am lookin for. Thx for sharing with us
You're welcome 😊
It is nice video Tim. Thank you.
You are welcome.
Great intro! just cleared my mind!
Excellent!
Thanks just got an assignment of school about mongo
You are welcome.
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
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.
Thanks for the information. Really liked the video.
You are welcome.
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 :)
very very helpfull tutorial, perfect explain about mongodb database. thank u master
Glad it was helpful!
Thanks for the video, very easy to follow along :)
You are welcome.
This was really helpful bro. thank you so much
Glad it helped!
Great explanation in simple way
Thanks!
Nice vid, more mongo pls!!!
Thanks. More will be coming in the future.
Great tutorial as always. Tutorial how and when to use relations in MangoDB may be helpful too. Thanks a lot.
I will add it to the list. Thanks for the suggestion.
wonderful tutorial!
Thank you for sharing!
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 });
}
Thanks for sharing.
It was great training, thanks Tim
You are welcome.
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]?
Yep, that will work.
Thank you! Just what I was looking for.
you save my life bro
Excellent!
Thank you so much! Loved this!
You are welcome.
Very Good One. Thanks. Big questions are Group, Index, Search Speed On non-Id columns, and datagridview datasource with all these not consistent documents.
Thanks for the suggestions.
Hey Tim, amazing videos. I live near Scranton PA. 😀
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.
IAmTimCorey sure definitely, I actually work in Conshohocken as .Net developer.
Thank you Tim
You are welcome.
One other advantage you missed was scaling is super simple in noSql Dbs
That is a big benefit.
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?
No, but there isn't a need for one.
If possible do a video on ACID - Comparison using SQL SERVER and MongoDB using an example.
I will add it to the list. Thanks for the suggestion.
AWESOME!
Really appreciated mate
I am glad my content has been helpful.
UTC - "The official abbreviation for Coordinated Universal Time is UTC. It came about as a compromise between English and French speakers. Coordinated Universal Time in English would normally be abbreviated CUT. Temps Universel Coordonné in French would normally be abbreviated TUC."
Thanks for sharing.
Thanks a lot, great tutorial :)
You're welcome!
In Cluj, Romania, Banca Transilvania Atm-s used to crash several times a day when somebody tried to deposit cash in his account. The Atm swallowed the cash, but did not put it into the depositors account. I learned to don't ever put money into an Atm, when my money got swallowed on a Friday evening, and I was going to leave the country for 3 weeks on the next day.
Sounds like they need a better system.
You are a great person! thank you so much.
Thank you for continuing your learning with Tim.
Thank you very much!
You're amazing man :)
You are welcome.
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?
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.
@@IAmTimCorey Thank you!
Thank you very much for such a great tutorial
You're very welcome!
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!
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.
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
I will add it to the list. Thanks for the suggestion.
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?
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.
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.
Thanks for sharing.
Great tutorial. Thank you!
Glad it was helpful!
Hi Tim, It appears the ReplaceOne has been made obsolete. What the is new way of doing the same thing for an Upsert?
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 });
}
Thank you so much! that was really helpful !
You are welcome. If you are looking for more MongoDB content, stay tuned. More is coming soon.
@@IAmTimCorey Awesome, I would really be interested not only by infos on MongoDB, but also a presentation of SQL/NoSQL differences and usage cases!
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 :)
awesome getting started thanks
You are welcome.
Thank you very much. Very nice video
You are welcome.
Hello Tim, the video was great! Do you have a video explaining how to implement a transactions in mongo DB?
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.
Thanks for sharing... This is enlightening
You are welcome.
I noticed that sometimes you use "_id" for the filter and sometimes "Id". I guess that using Id still works because of the BsonId decorator. If that is the case, wouldn't it be safer to always use "_id" to allow the MongoCrud to be generic and always work with whatever model you are mapping?
The problem is that _id doesn't conform to C# naming standards. I try to use Id wherever I can.
awesome video thanks for sharing !
Thanks for watching!
this is great video!
Thanks for trusting Tim with your skills.
Very helpful tutorial to start MongoDB with .Net. Can you please make some more tutorials to discuss more details about it?
I will add it to the list. Thanks for the suggestion.