Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# XML MVC database website
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 16-Apr-13 8:22am
Comments
learner'sbug at 16-Apr-13 13:35pm
   
what do you want to use XML for ?
Sergey Alexandrovich Kryukov at 16-Apr-13 14:53pm
   
I think it's clear. Please see my answer as well.
—SA
ryanb31 at 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 at 16-Apr-13 14:53pm
   
This is extremely simple; everything is already done in .NET FCL. Please see my answer.
—SA

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  
Comments
Maciej Los at 16-Apr-13 15:35pm
   
+5!
RDBMS[^]
Sergey Alexandrovich Kryukov at 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 Ferreira Casimiro at 16-Apr-13 17:47pm
   
+5! beautiful
Sergey Alexandrovich Kryukov at 16-Apr-13 18:01pm
   
Thank you very much, José.
—SA
learner'sbug at 16-Apr-13 17:48pm
   
great answer.. +5
Sergey Alexandrovich Kryukov at 16-Apr-13 18:01pm
   
Thank you very much.
—SA
abbaspirmoradi at 17-Apr-13 3:41am
   
this is greate and very helpful for me.thanx Sergey.
Sergey Alexandrovich Kryukov at 17-Apr-13 11:27am
   
You are welcome. Will you accept the answer formally (green button) then?
—SA
abbaspirmoradi at 18-Apr-13 10:45am
   
My pleasure sir.
Sergey Alexandrovich Kryukov at 18-Apr-13 10:54am
   
Good luck, call again.
—SA

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

  Print Answers RSS
0 BillWoodruff 360
1 Mathew Soji 309
2 DamithSL 225
3 Afzaal Ahmad Zeeshan 202
4 Maciej Los 190
0 OriginalGriff 6,249
1 Sergey Alexandrovich Kryukov 5,853
2 DamithSL 5,183
3 Manas Bhardwaj 4,673
4 Maciej Los 3,865


Advertise | Privacy | Mobile
Web02 | 2.8.1411019.1 | Last Updated 16 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100