LINQ to NHibernate 1.0 released

Tuna Toksoz, Chad Lee, and Oren Eini a.k.a Ayende have released LINQ to NHibernate 1.0. This version is still based on and limited by the criteria API of NHibernate, and still part of the NHContrib project. Which one would you rather use?
Function Authenticate(userName As String, hashedPassword As String) As Identity
    Dim Query = From Identity In Accounts _
            Where Identity.UserName = userName _
            AndAlso Identity.PasswordHash = hashedPassword
    Return Query.FirstOrDefault
End Function
Function Authenticate(userName As String, hashedPassword As String) As Identity
    Dim Query = m_Session.CreateCriteria(GetType(Identity)) _
                .Add(Expression.And( _
                   Expression.Eq("UserName", userName), _
                   Expression.Eq("PasswordHash", hashedPassword)) _
                .List().Cast(Of Identity)
    Return Query.FirstOrDefault
End Function
Aren't you tired of using magic strings in the criteria API? Steve Strong has done a TON of work on the HQL abstract syntax tree parser, which is a prerequisite for the more powerful HQL version LINQ to NHibernate that will be part of the main NHibernate project, not NHContrib. His work was sponsored by iMeta. The HQL AST has made it in to recently-released NHibernate 2.1, so the HQL version of LINQ to NHibernate can't be too far behind. - Jason LINQing like mad!
blog comments powered by Disqus