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

人盡茶涼 提交于 2019-12-23 10:34:47

问题


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...


回答1:


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.



来源:https://stackoverflow.com/questions/33160816/nhibernate-could-not-resolve-property-only-in-visual-studio-2015-with-a-leftou

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!