Is it possible to use `SqlDbType.Structured` to pass Table-Valued Parameters in NHibernate?

My first, ad hoc, idea was to implement my own IType. public class Sql2008Structured : IType { private static readonly SqlType[] x = new[] { new SqlType(DbType.Object) }; public SqlType[] SqlTypes(NHibernate.Engine.IMapping mapping) { return x; } public bool IsCollectionType { get { return true; } } public int GetColumnSpan(NHibernate.Engine.IMapping mapping) { return 1; } public … Read more

DateTime precision in NHibernate and support for DateTime2 in NHibernate SchemeExport

Actually the NHibernate reference states that the DateTime nhibernate type will store the .NET DateTime as an SQL datetime truncated at the second level (no millisecond granularity) As such it provides the Timestamp NHibernate type (type=”Timestamp” in the mapping) which will store a .NET DateTime as an SQL datetime without truncation. Note here that an … Read more

How do I view the SQL that is generated by nHibernate?

You can put something like this in your app.config/web.config file : in the configSections node : <section name=”log4net” type=”log4net.Config.Log4NetConfigurationSectionHandler,log4net”/> in the configuration node : <log4net> <appender name=”NHibernateFileLog” type=”log4net.Appender.FileAppender”> <file value=”logs/nhibernate.txt” /> <appendToFile value=”false” /> <layout type=”log4net.Layout.PatternLayout”> <conversionPattern value=”%d{HH:mm:ss.fff} [%t] %-5p %c – %m%n” /> </layout> </appender> <logger name=”NHibernate.SQL” additivity=”false”> <level value=”DEBUG”/> <appender-ref ref=”NHibernateFileLog”/> </logger> </log4net> … Read more

NHibernate.MappingException: No persister for: XYZ

Sounds like you forgot to add a mapping assembly to the session factory configuration.. If you’re using app.config… . . <property name=”show_sql”>true</property> <property name=”query.substitutions”>true 1, false 0, yes ‘Y’, no ‘N'</property> <mapping assembly=”Project.DomainModel”/> <!– Here –> </session-factory> . .

NHibernate: How do I XmlSerialize an ISet?

NHibernate serialization has been treated a lot on stackoverflow. See: C# Castle ActiveRecord: How to elegantly (XML) serialize ActiveRecord objects? How do I serialize all properties of an NHibernate-mapped object? NHibernate and WCF Serialization(Unidirectional) JSON.NET and nHibernate Lazy Loading of Collections Which .NET JSON serializers can deal with NHibernate proxy objects? DTOs vs Serializing Persisted … Read more