简体   繁体   中英

How do I use a Database with my Discord Bot? (Using Discord.Net and psotgresql)

Been working on a bot in Discord.Net and now I want to use a database to keep track of things. I don't have much in the way of experience with them, but I selected to go with Postgres.

Not sure what to do next and I've had difficulty finding resources relating to this.

Just to let you know, SO generally doesn't want questions about recommendations like this. But here, I found a few places that might help you out:

Here's the documentation from the site, which also links some resources and tutorials . Particularly, the TutorialsPoint link on that page looks promising (just from a quick glance).

Its a broad question, but as a general rule, if you dont know that much about databases, there is an "easy" solution for you.

First learn the basics about databases in general. And then you have 2 options:

  1. Go with an ORM and make a code first approach, which will let you code and dont worry that much about the database.

  2. Or make a database and then attach an ORM or Micro ORM, you can also use something like a DAL, which probably will be the fastest option but the most hard to code. ORM will let you use LINQ which later will be translated to POSTGRES SQL code (in this case, if you are using SQL SERVER it would be ANSI SQL).

There is no easy or short answer to your question. If i were you I would investigate about EntityFrameWork, This is a good place to start learning about ORM and in my opinion humble is one of the most easy ones to use.

Also investigate about code patterns, use services, which consume the DbContext (this would be the mapping of the database in the memory of your application, not the whole, but the barebone, you will get it once you start learning about these things). Try to learn the Repository Pattern.

And most of all be patient, it will take some time for you to get up to speed with a whole lot of concepts, such as migrations, entities, IoC, and more.

Here is a possible start for your journey https://www.entityframeworktutorial.net/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM