views:

50

answers:

2

So far all the serialization examples I have found on the web are related to storing arrays or list in a file. With each class of object having to be serialized into their own file such as a ".bin". The root of my problem is that I want to have the information for my product local stored, but I'm so use to working with sql. It's hard for me to visualize how to store information locally. If C# is anything like asp I should be able to connect to an Access database, but that pretty much defeats one of the ideas of serialization which is user non-readability. Is there a serialization method similar to using table and fields or at least allowing you to store all user information in one file?

+1  A: 

Check out NHibernate. That will give you your 'database-like' storage.

If it's human-readability you're after, consider serializing your objects using XML. .Net has decent support for serializing (and deserializing) objects using both XML and binary formats.

The tutorial I used for learning serialization in C# is this CodeProject article.

Update:

I misread one point you made: serialization does not necessarily mean human-readable or not - if you decide to serialize, figure out if you want the data readable or not. Binary serialization is likely to be more compact and less readable.

Charlie Salts
He mentions one of the benefits of serialization is **non** -readability.
Benny Jobigan
Serialization does not mean the data is readable or not. I've used serialization techniques that are both human-readable and not. If the OP is worried about protecting serialized data, then encryption or at least basic obfuscation should be used.
Charlie Salts
+1  A: 

You could use a ADO.NET DataSet that is serialized and stored locally. It will contain all of the data structures that you're familiar with and allow you to query the data the way you seem to want to and if you serialize it with a Binary Serializer, it will be unreadable to end-users.

Also, you could look at SQLite as an alternative to using DataSets.

SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine. SQLite is the most widely deployed SQL database engine in the world. The source code for SQLite is in the public domain.

NHibernate with SQLite is a great combination as well.

Cheers.

Dave White