Jeff
Jeff

Reputation: 103

How do you go about saving objects into an SQLite database?

I am new to database's in general. I have been learning C# and at a point to start applying a database to my projects. I decided to start learning SQLite since from what I've read it is pretty simple to use and learn. I am confused on how to submit object into a database.

Example: I have a class that is a deck, in that class I have a list of Card, which is a separate class that has properties. I want to find away to save the List in the database. From what I can see you can only save text or integers? But I'm sure I must be wrong.

I've been searching for tutorials that save objects to SQLite but all I've found are tutorials that have super simple examples of storing a text and returning it. Can anyone explain to me how this is done, or direct me to reading material/tutorial that explains this?

I have had such a hard time figuring out databases, and it is frustrating! Everyone tells me how easy it is, but it looks so foreign to me. I don't know why I'm having such a hard time.

Upvotes: 0

Views: 1715

Answers (1)

Anestis Kivranoglou
Anestis Kivranoglou

Reputation: 8204

There is no reason to make your life more complicated that it has to be. ORM tools are the way forward for storing related objects into databases.

Since you use c# entity framework is one of them and very powerful. See this tutorial for SQLite.

https://learn.microsoft.com/en-us/ef/core/get-started/overview/first-app?tabs=netcore-cli

Upvotes: 1

Related Questions