nhibernate 5之后的不同查询(使用oracle)

问题描述 投票:0回答:1

从4.1升级到5.2后,nhibernate创建的查询略有不同,在不受欢迎的地方放置了“ OR”。

4.1

...,
...,   
(select cast(count(guia5_.ID) as NUMBER(10, 0))
  from SAM_GUIA guia5_

 where guia5_.PEGID = peg1_.ID                        <<<<<<<<<<<<<<<

) as col_41_0_,

5.x的

...,
...,   
(select cast(count(guia5_.ID) as NUMBER(10, 0))
   from SAM_GUIA guia5_

  where guia5_.PEGID = peg1_.ID                        <<<<<<<<<<<<<<<
     or (guia5_.PEGID is null)                         <<<<<<<<<<<<<<<
    and (peg1_.ID is null)                             <<<<<<<<<<<<<<<

) as col_41_0_,  

与linq有关的查询是:

...,
...,
RecordCount = (from c in repositoryGuia.All()
           where c.PegId == b.Id
           select c.Id
           ).Count(),

有关映射的更多信息:

  • c.PegId:int?
  • b.Id:int

使用NHibernate 5.2.6和Fluent 2.1.2。

为什么版本5转换为其他SQL语句?

nhibernate fluent-nhibernate
1个回答
2
投票

这是一个已知的5.x问题GH-1860。何时以及为何改变行为的详细说明here。AFAIK没有LINQ的解决方法,因此如果hql / QueryOver适合您,则必须使用hql / QueryOver。

但是有一个开放拉取请求here应该可以解决此问题。因此,也许在5.3中将得到修复。

© www.soinside.com 2019 - 2024. All rights reserved.