GIGA BRAIN
❔ Question about setting up dependency injection (console app with no async stuff)
So I've been trying to set up a dependency injection in my program for the first time to no avail. From what I've learned, a dependency injection allows you to use methods from another class without having to explicitly instantiate a new instance of the class which allows for loosely coupled code and less dependencies.
I was told I should be injecting my DBContext instead of calling a new context every time I do a database action. I think the way I have been approaching this fix is wrong in that I'm creating an interface for my Helpers class when in reality I should be making an interface for my PhoneBookContext class. Am I on the right track? Any feedback is appreciated.
Pasted code:
https://paste.mod.gg/hhwsmajvkxnq/2
78 replies
❔ Adding database entries with EF Core
I'm completely new to EF Core. I have two tables, Contact and Number. The two tables are connected through FK ContactId in the Number table. I want to create an entry but not sure how I would be able to add information to both tables, here is the pastebin:
https://paste.mod.gg/cilvbumgkbvh/0
(Also, does anyone know how to make a field a foreign key after i've done the add-migration and update-database?)
27 replies
❔ Accessing json results for a weather api console app
https://paste.mod.gg/jtzzrouisnhf/0
I'm trying to access the temperatures, but when I try to get back a list according to how i have it in the WeatherInfo.cs class, it doesn't work. Any suggestions?
20 replies
Help with Simon game logic
I'm trying to code this game: https://github.com/dotnet/dotnet-console-games/tree/main/Projects/Simon
I'm currently stuck on trying to add a pattern to a list.
Currently I have an array (string[] Renders) that holds each frame state of the game and a method that shows one of the patterns randomly.
My thought process on the game logic is that after every pattern is shown and correctly repeated, it is added to the list. Rinse and repeat, but obviously call the list with it's previous pattern history.
Link to code:
https://paste.mod.gg/qieexdztawyd/0
8 replies
✅ Using an async method to print contents of an array
I'm trying to make a simon game and the next step I've decided on is that I need a method to draw the simon map. I'm using an async method so that I can delay the time in which it takes to show the next map, but when I call the method it only shows the first map. When I use the code without putting it inside a method, it works fine. I don't understand what I'm doing wrong:
29 replies