I design an objected oriented application using C# with database back end, for some time I was building same application using procedural way in which I feel storing data to database is little bit easier using simple SQL statement.
I my application I want to store the objects attribute to database, for example for an item object
Class Item {
private string itemId;
private string itemname;
private Invoice inv; //assume Invoice object
//method
public bool storetodb() {
//..something like this
}
}
The problem is I feel a little bit complex when storing and retrieving object data to database. When I searched on some resource also they use like collection class to map between object on the application and relational database. Even I have searched SO but I couldn’t find any related information. One source I got was
- http://www.codeproject.com/KB/database/AONETOOP.aspx ….. The author uses collection to store and retrieve data
- I hear also about ORM technology although I have never tried it.
So what is good practice for designing these types of applications?
can you give any links, article, recommended book or response for tackling these types of problem.
Thanks
Update
It seems ORM tools mainly nhibernate is most promising from your suggestion.
Thanks all of for your help, I will consider ORM
You should invest some time to investigate one or two ORMs. If you’re working with .NET 4.0, you should give the new implementation of Entity Framework a try. Another widely used ORM is NHibernate, which is a .NET version of Java’s famous Hibernate ORM. However, from my own standing, ensure that you encapsulate the whole ORM into your Data Access Layer (DAL) so you can use native ADO.NET if the ORM ever hits the wall.
Another option are EAV CR databases. However, it’s not the easiest way to learn how to live with. (I did that more than five years.)