"Introduction to NHibernate" presentation and demo

January 30, 2011

Last week I presented a lecture about NHibernate to the .Net division of E4D Solutions. Now all of you can download the presentation and the demo sources (attached to this post). The zip file contains: NHibernteDemo.pptx - this is the PowerPoint presentation. NHibernateTest.mdf - this is the database used for the demo. Attach this database to your local SQL Server. 6 folders containing the demo sources split into stages. The solutions are for VS2010 and contain 2 projects: Client and BusinesLogic. Note that the Client are the same for all stages and only the BusinessLogic projects are changed. Notes:  If you don't have NHibernate binaries you...
no comments

Tip of the day for NHibernate #2: show_sql and format_sql

January 19, 2011

As always with tips, either you already know this or it would be invaluable. This time I'm talking about 2 configuration properties: "show_sql" and "format_sql". To switch on these options, add the corresponding lines to your hibernate.cfg.xml file as in the following example: <?xml version="1.0" encoding="utf-8" ?> <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">   <session-factory>     <property name="connection.connection_string">Data Source=.;Initial Catalog=NHibernateDemo;Integrated Security=True</property>     <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>     <property name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property>     <property name="show_sql">True</property>     <property name="format_sql">True</property>     <mapping assembly="BusinessLogic"/>   </session-factory> </hibernate-configuration> What is does? The โ€œshow_sqlโ€ property tells NHibernate to output all the SQL statements it executes onto the console. This way you can see exactly what...

Tip of the day on NHibernate: IntelliSense for the hbm files

January 11, 2011

If you're using NHibernate and writing your NHibernate mapping files (*.hbm.xml) by hand, (as opposed to using Fluent NHibernate for example), then you'll probably be interested in the following tip (unless you already done that :-) ) You can have IntelliSense validation and auto-completion in the XML editor for NHibernate xml files (both the *.hbm.xml and hibernate.cfg.xml) by following the following steps: 1. Inside VS, select XML->Schemas. 2. Click "Add..." 3. Browse to the "Required_bins" folder inside of your NHibernate folder (e.g. "C:\Nhibernate3.0\Required_bins") 4. Select both "nhibernate-configuration.xsd" and "nhibernate-mapping.xsd" file and click "Open". The 2 schemas will be added to the list: 5. Click OK...
no comments