NHibernate Mapping doesn't work -
i created console application, database, model, xml-file , wrote code
using system; using system.reflection; using nhibernate.cfg; using nhibernate.dialect; using nhibernate.driver; namespace nhibernatedemo { internal class program { static void main(string[] args) { try { var cfg = new configuration(); cfg.databaseintegration(x => { x.connectionstring = "server=.; database=nhibernatedemo; integrated security = sspi;"; x.driver<sqlclientdriver>(); x.dialect<mssql2008dialect>(); }); cfg.addassembly(assembly.getexecutingassembly()); var sessionfactory = cfg.buildsessionfactory(); using (var session = sessionfactory.opensession()) using (var tx = session.begintransaction()) { var customers = session.createcriteria<customer>() .list<customer>(); foreach (var customer in customers) { console.writeline("{0} {1}", customer.firstname, customer.lastname); } tx.commit(); console.writeline("enter key exit..."); console.readkey(); } } catch (exception e) { } } } }
i didn't error , exception, didn't information database too, string "enter key exit..."
in console.
what's wrong?
upd
xml-file
<?xml version="1.0" encoding="utf-8" ?> <hibernate-mappin xmlns="urn:nhibernate-mapping-2.2" assembly="nhibernatedemo" namespace="nhibernatedemo"> <class name="customer"> <id name="id"> <generator class="native" /> </id> <property name="firstname"/> <property name="lastname"/> </class> </hibernate-mappin>
have added xml mapping files assembly.getexecutingassembly())
? have make embedded resource. otherwise have behavoir describing.
go properties of files change build action.
Comments
Post a Comment