Hello,
Im doing a project with C# winforms. This project is composed by:
- Client project: Windows Forms where user will call the CRUD operations;
- Server project;
- Common Project: This project will hold the models (in the image only have the model Item);
- ListSingleton Project: Remote Object that will do the operations on the models;
Im trying to use a 3 layers style in which the CLIENT and the SERVER will be the views layer, the LISTSINGLETON will be the controller layer (where all objects are created), and COMMON project is the models layer...
I already have all the communication working, but now I need to work on the persistence of the data in a mysql database. I was trying to use nHibernate but I’m having some troubles.
My main problem is how to organize my hibernate configuration. - In which project do I keep the mapping? Common project?
In which project do I keep the hibernate configuration file (App.config)? ListSingleton project?
In which project do I do this:
Configuration cfg = new Configuration(); cfg.AddXmlFile("Item.hbm.xml"); ISessionFactory factory = cfg.BuildSessionFactory(); ISession session = factory.OpenSession(); ITransaction transaction = session.BeginTransaction();
Item newItem = new Item("BLAA"); // Tell NHibernate that this object should be saved session.Save(newItem); // commit all of the changes to the DB and close the ISession transaction.Commit(); session.Close();
In the ListSingleton project? Altho I had reference to the Common Project in the ListSingleton I keep getting error in the addXml line…
- And when I have 2 projects one with the models & mappings and another where ill use the hibernate (this project has a reference to the models project), how do i do "cfg.AddXmlFile("User.hbm.xml");" I keep geting "Could not configure datastore from file User.hbm.xml" When i use this 2 project structure.
My mapping is correct because I tried with a one-project solution and it worked :X