我有以下Nhibernate LINQ查询:
var query = from c in session.Query<Customer>()
where
c.EmailAddress == customer.EmailAddress ||
(
c.Address1 == customer.Address1 &&
c.City == customer.City &&
c.State == customer.State &&
c.Postal == customer.Postal &&
c.FirstName == customer.FirstName &&
c.LastName == customer.LastName
)
select c;
我希望生成的SQL语句看起来像:
select
...
from
dbo.Customers customer0_
where
customer0_.EmailAddress=@p0 or
(
customer0_.Address1=@p1
and customer0_.City=@p2
and customer0_.State=@p3
and customer0_.Postal=@p4
and customer0_.FirstName=@p5
and customer0_.LastName=@p6;
)
但是我从调试日志中看到的是:
select
...
from
dbo.Customers customer0_
where
customer0_.EmailAddress=@p0
or customer0_.Address1=@p1
and customer0_.City=@p2
and customer0_.State=@p3
and customer0_.Postal=@p4
and customer0_.FirstName=@p5
and customer0_.LastName=@p6;
请注意,where子句的地址部分没有分组。这是故意的吗?我应该以不同的方式格式化我的查询,还是这是一个错误?
答案 0 :(得分:1)
生成的SQL是正确的;不需要括号。