Click here to Skip to main content
15,893,622 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi every body.
Can use a Xml file for small mvc3 website?It have a Log in for edite delete ,and have pages for show news.
Posted
Comments
[no name] 16-Apr-13 13:35pm    
what do you want to use XML for ?
Sergey Alexandrovich Kryukov 16-Apr-13 14:53pm    
I think it's clear. Please see my answer as well.
—SA
ZurdoDev 16-Apr-13 13:55pm    
I don't think you should but of course you can write code to interface with xml. You'll have to do all the code though.
Sergey Alexandrovich Kryukov 16-Apr-13 14:53pm    
This is extremely simple; everything is already done in .NET FCL. Please see my answer.
—SA

1 solution

If your XML file is small enough to keep all the data in memory, this is a simple easy way to implement a kind of a database; and you would enjoy the huge benefits of purely object-oriented database, no mapping code. If this is not the case, however, such approach would be very awkward, and I would strongly discourage it, recommend some RDBMS, which could be open-source and more or less light weight.

That said, if using XML-based in-memory object-oriented database, first thing you should require is total isolation of storage from database functionality. Your database should be some object graph of general shape (first of all, you should not assume it is a tree), and the storage should be 100% agnostic of data types. These primary goals are fully satisfied with Data Contract:
http://msdn.microsoft.com/en-us/library/ms733127.aspx[^].

Please see my past answers where I advocate this wonderful approach:
How can I utilize XML File streamwriter and reader in my form application?[^],
Creating property files...[^].

Note that you won't need to work with XML manually. Your object graphs will be stored in full and later restored in memory. Circular dependencies (remember, I mentioned that the object graph is not required to be a tree), the approach will still perfectly work. Besides, you can easily evolve the database schema and provide backward compatibility with files created in earlier versions of your software.

If the main criterion (all-database-in-memory) cannot be guaranteed, I would say that the effort would not worth the effort, not at all. In this case, opt for RDMBS. Review this set:
http://en.wikipedia.org/wiki/List_of_relational_database_management_systems[^],
http://en.wikipedia.org/wiki/List_of_object_database_management_systems[^].

Good luck,
—SA
 
Share this answer
 
Comments
Maciej Los 16-Apr-13 15:35pm    
+5!
RDBMS[^]
Sergey Alexandrovich Kryukov 16-Apr-13 15:49pm    
Thank you, Maciej. (Well, I assumed that OP knows what "RDBMS" means, but thank you again for a link.)
—SA
José Amílcar Casimiro 16-Apr-13 17:47pm    
+5! beautiful
Sergey Alexandrovich Kryukov 16-Apr-13 18:01pm    
Thank you very much, José.
—SA
[no name] 16-Apr-13 17:48pm    
great answer.. +5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900