Is there a serialization method similar to a database

So far, all the serialization examples that I have found on the Internet are related to storing arrays or a list in a file. Each object class must be serialized into its own file, for example, ".bin". The root of my problem is that I want the information for my product to be saved, but I'm so used to working with sql. It’s hard for me to imagine how to store information locally. If C # is something like asp, I should be able to connect to the Access database, but that pretty much wins out one of the serialization ideas that is not readable by the user. Is there a serialization method similar to using a table and fields, or at least allowing to store all user information in a single file?

+4
source share
2 answers

You can use the ADO.NET DataSet, which is serialized and stored locally. It will contain all the data structures that you are familiar with, and allows you to query the data as it seems to you, and if you serialize it using the Binary Serializer, it will be unreadable to end users.

Alternatively, you can look at SQLite as an alternative to using DataSets.

SQLite is a software library that implements a standalone, serverless, zero configuration, transactional mechanism of SQL DBMS. SQLite is the most widespread SQL query database engine in the world. The source code for SQLite is in the public domain.

NHibernate with SQLite is a great combination.

Greetings.

+1
source

Check out NHibernate . This will give you your repository similar to a database.

If you are reading humanly, consider serializing objects using XML..Net has decent support for serializing (and deserializing) objects using both XML and binary formats.

The tutorial that I used to study serialization in C # is this CodeProject article .

Update:

I incorrectly thought over one of the following conclusions: serialization does not necessarily mean readability or not - if you decide to serialize, find out whether you want to read the data or not. Binary serialization is likely to be more compact and less readable.

+1
source

Source: https://habr.com/ru/post/1314604/


All Articles