alkampfer on December 30th, 2011

When you work with ORM like nhibernate, having a tool like nhprof is the key of success. But even with NHProfiler you could not prevent people of doing wrong stuff because they do not use it . I have a simple scenario, a developer changed a method on the server lazily fetching a property of [...]

kick it on DotNetKicks.com

Continue reading about Unit test NHibernate query to verify N+1

alkampfer on December 1st, 2011

Another advantage of storing properties of entities into a state object based on a Dictionary, is the ability to easily serialize objects in custom formats. As an example I create an XML serializer that is capable to serialize an entity in a custom XML format. I used this simple serializer to create a NHibernate User [...]

kick it on DotNetKicks.com

Continue reading about Custom XML Serialization

alkampfer on August 29th, 2011

1: DateAdd(dd, T.AnalysisFrequence, :refdate) Quite often I use SQLite to create Unit Tests of NH queries with a fast In-Memory database, and then run the queries against a standard Sql Server database. Today I have this problem, an HQL query uses the DateAdd Sql Server function 1: DateDiff(dd, T.AnalysisFrequence, :refdate) In this query with the [...]

kick it on DotNetKicks.com

Continue reading about Use SQLite to test NH–DateAdd function

alkampfer on August 2nd, 2011

Some time ago I blogged about a technique to use SqLite in Unit testing when you have nhibernate mapping that targets Sql Server tables in a schema different from dbo. The problem was: if you specify the schema name in the mapping of a class, then you are not able to execute the test in [...]

kick it on DotNetKicks.com

Continue reading about Using schema with NHibernate and SqlLite

alkampfer on July 28th, 2011

In a previous post I described a technique to insert query hints into NHibernate query with the use of comments. Testing this code in a real project lead to a strange exception when I issue queries with ICriteria The query should start with ‘SELECT’ or ‘SELECT DISTINCT’ This happens because ICriteria queries inserts comments inside [...]

kick it on DotNetKicks.com

Continue reading about A strange bug in NHibernate 2.1