Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nhibernate could not resolve property (Only in Visual Studio 2015) with a LeftOuterJoin

I need some help as can't really explain this one. We have a semi complex nhibernate query:

var query = _tyreRepository.Session.QueryOver<Tyre>(() => tyreAlias)
     .JoinQueryOver<Pattern>(() => tyreAlias.Pattern,  () => patternAlias)
       .JoinQueryOver<Brand>(() => patternAlias.Brand, () => brandAlias)
     .JoinQueryOver<RimSize>(() => tyreAlias.RimSize,  () => rimSizeAlias)
              .JoinQueryOver(() => tyreAlias.SpeedIndex, 
                             () => speedIndexAlias, JoinType.LeftOuterJoin);

Which works fine in Visual Studio 2012, we recently upgraded to Visual 2015 and now this query doesn't work; when you use a where on the speed index:

query.Where(() => speedIndexAlias.SpeedKm >= speedKms);

The query works fine otherwise.

Spent a long time debugging rolling back code nothing worked. Then we got the same project complied it in visual studio 2012 works fine. We can't work out why when we compile the project in visual studio 2015 this query no longer works (with no changes at all to the query).

I really like all the new language changes in 2015 but our website breaks when we compile our code in visual studio 2015...

like image 260
Daniel Avatar asked Sep 26 '22 11:09

Daniel


1 Answers

Ok I did find a solution. You need to upgrade nhibernate to the latest version due to an issue with the C# Roslyn compiler in visual studio 2015. Unfortunately doesn't look like older versions of nhibernate have a fix for this at all.

https://nhibernate.jira.com/browse/NH-3795

So if you want to use visual studio 2015 and you use nhibernate you have to upgrade nhibernate currently. Must be build 4.04.4000 which I can confirm does work with fluent 2.0.3.

like image 63
Daniel Avatar answered Sep 29 '22 00:09

Daniel