Комментарии:
I am happy you got a partnership with MongoDB, congrats! You deserve it you make great videos
ОтветитьI would like to ask, When you request certain fields from a "Document", Does MongoDB returns the whole Document? or it just returns the selected elements over the wire?
ОтветитьEven though this has pretty small models, the data access is already kind of blowing up. If you created say, a UserDataAccess class, a lot of the code would be very similar to the ChoreDataAccess class. This is good for learning, but in production would it be preferable, and possible, to have the Model classes inherit from an interface class, then use reflection to write the DataAccess functions.
So instead of a CreateChore(ChoreModel chore) and CreateUser(UserModel user), you would have a function Create(IModel). Then in the body you would use reflection to get the Model type, UserModel, ChoreModel, etc., and the ChoreCollection string can be figured out from the Model name.
i have a question. lets say you have a many to many relationshio have a class Students and Subjects. and you want to get a list of all the subjects a student is doing. How do you query the sub document subjects (array/list of type subjects )in students?
Ответитьi have two classes Students and Subjects. A student can be have many subjects and a subjects and have multiple students.
so now that i have created a databse and have added a student object to it and assigned a subject to the student.
how can i get all the subjects that a particular student is assigned to? C# am new to mongodb please help
Dude... Its 2AM. I found this video and got stuck on it. Now I don't know if I'll be able to sleep because I'm already thinking about how to use it. Can't wait to go after your other content on Mongo DB and binge on it. Thanks so much for this video.
ОтветитьTim, this video made me to try mongodb, thanks. By the way, in old video about MongoDB you have used Guid Id. Is there any difference between string Id and Guid Id?
ОтветитьQuick question: I downloaded the source code and when I ran it, the CompleteChore method I got an error that said I couldn't use transactions in a local MongoDB database. Is this always the case that in order to use transaction I have to be using MongoDB Atlas or is there a setting where I can turn on transactions for a local MongoDB database?
ОтветитьI have no regrets by changing from SQL to NOSQL
ОтветитьAre there any options if a person wants transactions for mongo db but they require completely offline as well. Because there can be an app being built where if somebody loses their internet connection, they can still do their work. The only problem with atlas is if there is an internet outage, then they can't do any work. If it was stored locally, then the person can still do their work.
ОтветитьI really loved this video though. The fact it showed data access involving more than one collection was good.
Since I see a lot of repetition, this inspired me to create a source generator.
So what will happen is the cross platform part will not even need the attributes. However, the source generator can make the mongo models, do all the mappings.
Plus can specify collection names for the models so a person is not repeating themselves. Even found I can create a method that takes in an expression for even more flexibility. So a person can focus on the business logic and not the boilerplate code.
Hey
Is there any series build on mongodb?
If yes link please
Creating a "MongoModelBase" has so far been my best approach, where I can keep an Guid Id defined as an abstract property + a CollectionName that i can set in each model, so I dont have to repeat myself when calling the API.
Also I have created a override on ToString() so its easy to debug the models onto console.
Thank you , for the best lesson👍
ОтветитьThanks!
Ответитьsession.StartTransaction(); sending an error "Standalone servers do not support transactions.'"
ОтветитьGood video!
I have a question about that order of actions:
1) A reads document
2) B reads document
3) A and B modifies document
4) A writes document
5) B writes document
Will changes of A be discarded? And how to prevent that?
By the way, pass is NotGoingToTellX - mission failed :D
Does anyone know how to set Model fields as optional?
ОтветитьSir, I have query and i hope you would help me Sir.
Problem is I need to update a document but i want to add the value to the existing value of a field not replace.
eg. Qty was in db like 10 and now i have Qty = 2 so after updating i need it to be 10+2 = 20 not 2.
So what to do? does mongoDB supports sub query like sql or what?
plz help me Sir.
This is awesome
Ответитьi appreciate your effort to give us this valuable information about nosql db and mongodb, relay thank you for your effort
Ответить@IAmTImCorey Quick question on around 29 minutes in, do you need to initialize a new MongoDB instance for each request? Cant you just cache it?
ОтветитьThanks Tim. Learner (and user!) of a good bit of your code. Won't forget it!
Ответитьdoes var result = collection.FindAsync(_ => true); result.ToList(); (separetly)
is the same sync as doing: collecton.Find(_ => true).ToListAsync(); ???
because for me is easier and in a one line.
Out of curiosity wouldnt other devices running your application be able to decompile it and see your login?
ОтветитьHi good day.
After completing the initial code, I am getting this error on Mac
Could not execute because the specified command or file was not found.
Possible reasons for this include:
* You misspelled a built-in dotnet command.
* You intended to execute a .NET program, but dotnet-/Users/username/Projects/MongoDBApp/MongoDBDemo/MongoDBDemo/bin/Debug/net6.0/MongoDBDemo.dll does not exist.
* You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
Any clue what could be the reason?: already installed the Net just in case. but not corrected.
🎉
ОтветитьThanks, great content. Easy to follow for novice.
ОтветитьHello Tim! Great class as always!
I have a question, this may not be the focus of this class but should't we have to put the "using" statement on the ConnectToMongo or in the methods that use the Mongo connection to guarantee that the connection will be closed as soon as we finish the database interaction ?
So helpful, thanks Tim! You've helped me with a lot over the years.
Do you have any other videos covering more mongdb driver functionality? Like, can you sort, skip, limit, etc on Async functions (.FindAsync)? When evaluating a filter, should you make both objects Bson values (BsonValue.Create()), or can you compare a Bson value to any object?
The easy way 1 hour 10 mins?
ОтветитьThis was an extremely helpful tutorial, as I'm quite new to this. Quick question unrelated to the subject, but related to Visual Studio:
Why are named parameters formatted as smaller gray fonts in your copy of Visual Studio, but not in mine? (I just installed Visual Studio 2022, all defaults).
Also, why are your constants a bold font, but they're formatted the same as any other variable in a default install? Did Microsoft just change the formatting or did you customize yours? I think the way your code is formatted is much easier to read.
hey, just my honest opinion here. first of all, thanks a lot for the video! it is very helpful for a beginner in working with databases. what really helped me in your tutorial is the slow and in-depth explanation of what is going on with all the unknown key words like [BsonRepresentation(...)]. On the other hand I lost you really fast in minute 18 when you started jumping around files really fast.
Overall thank you a lot! for the awesome video!
Thank you very much
ОтветитьDude, with this clarity and putting the interests of the newbies up front... if you write a "Mobile App Development with .NET MAUI and MongoDB" book... you'll be a millionaire 😄
ОтветитьExcellent video. I really like this teaching style and working along to create the project!
ОтветитьOne year later I am back and this example is just amazing: straight to the point, and started with Winforms and connection to cloud at once. Really simple and well explained. Thank you.
ОтветитьThis guy is posting same videos to get views the same tutorial was published with different name few years back... This kind of content can consfuse many.. Please dont do like this @Corey...
ОтветитьHi
var db = client.GetDatabase(databaseName);
When I enter this line I get a red line under GetDatabase. the option is not available in visual studio. Could you please help.
I really don't like the idea of having data out of sync. If I'm storing a person and then using them in a related object I expect their data to match without my having to manually go back and fix it.
Ответить"We need to go deeper" achievement re-unlocked
Ответитьthank yo so much for this i really appreciate, but now I will like to know if you have a course that explain how to get the data from Mongodb i.e to get a particular property from the DB and show in WPF form. i will really appreciate a response
ОтветитьEven tho this is 2 years old, can you do a sequel and show how to make this connection into a windows form app or a wpf app?
ОтветитьThank you for this step by step explanation!
ОтветитьHi! I have a question. You seem to be using the compass to get access to the Database outside of the program, and if I recall, this is just a UI to access it, the database is actually stored in the files of MongoDB itself, right ? If so, that means the database isn't embedded in the C# project, it's just connecting to it from where it is. Is there any way to change this ? To make the database files a part of the project, so that they export with it when (for example) publishing and then using it on another PC ?
I'm asking because I'm working on a game for my studies exam, and I need to store the different Game Objects data inside of a DB, along with some other game elements and mechanics. And I obviously don't want to reinstall MongoDB everytime I switch PC and class for a presentation or just working on it. Maybe that isn't possible, but I still ask. Or maybe there is another way, another Database (More likely NoSql) that exists that could achieve this ?
I hope you'll see my comment!