LINQ generated NHibernate and Entity Framework SQL (JOIN)

In continuation of a previous blog which compared 2 simple SELECT statements between NHibernate and Entity Framework, I do the same with the joining of 2 tables together.

NHibernate

Figure 1 shows the LINQ to NHibernate query which selects all the data from the PostForNHibernate table, joins with the BlogForNHibernate table using the foreign key where the BloggerName is Benjamin Perkins.

image

Figure 1, LINQ to NHibernate JOIN with Lambda Expression

Figure 2 shows the data result and the generated SQL from the source code shown in Figure 1.

image

Figure 2, LINQ to NHibernate generated SQL – JOIN

Entity Framework

Figure 3 shows the LINQ to Entities query which selects all the data from the Post table, joins with the Blog table using the foreign key where the BloggerName is Benjamin Perkins.

Figure 3, LINQ to Entities with Lambda expression

Figure 4 shows the data result and the generated SQL from the source code shown in Figure 3.

image

Figure 4, LINQ to Entities generated SQL – JOIN

Conclusion

The SQL queries are almost exact excluding the placement of the search variable ‘Benjamin Perkins’. I am almost convinced that the queries created by both NHibernate and Entity Framework are, at least at a simple level, the same.

I will perform some more tests with some Aggregates and commands like GROUP BY and ORDER BY and let you know the outcome.