Why? They are exactly the same, except for the parentheses, which are redundant.
a AND b OR c = (a AND b) OR c a OR b AND c = a OR (b AND c) AND always has precedence over OR. /G 2011/9/22 sdhjl2000 <[email protected]> > now i'm using nhibernate 3.2 as the orm,when i write code like this: > > PostReaderBll postReaderBll=new PostReaderBll(); > var query = from p in postReaderBll.Query() > where (p.Post.Flag == (int)PostType.Post && > p.Post.MailState == (int)MailState.Normal) || (p.ReceiveUser == > LoginUser.UserIdentity && p.Post.Flag == (int)PostType.Mail && > p.Post.MailState == (int)APSP.Form.MailState.Normal) > select p; > i get this sql: > > SELECT TOP ( 10 /* @p0 */ ) ID1_70_, > IsRead2_70_, > ReceiveU3_70_, > ReadDate4_70_, > Flag5_70_, > Label6_70_, > PostID7_70_ FROM (select postreader0_.[ID] > as ID1_70_, > postreader0_.[IsRead] as IsRead2_70_, > postreader0_.[ReceiveUser] as ReceiveU3_70_, > postreader0_.[ReadDate] as ReadDate4_70_, > postreader0_.[Flag] as Flag5_70_, > postreader0_.[Label] as Label6_70_, > postreader0_.[PostID] as PostID7_70_, > ROW_NUMBER() > OVER(ORDER BY CURRENT_TIMESTAMP) as > __hibernate_sort_row > from PostReader postreader0_ > inner join Post post1_ > on postreader0_.[PostID] = post1_.[ID] > where post1_.[Flag] = 1 /* @p1 */ > and post1_.[MailState] = 0 /* @p2 */ > or postreader0_.[ReceiveUser] = 'admin' /* @p3 */ > and post1_.[Flag] = 0 /* @p4 */ > and post1_.[MailState] = 0 /* @p5 */) as query > WHERE query.__hibernate_sort_row > 0 /* @p6 */ ORDER BY > query.__hibernate_sort_row > but i need the where like this: > > ( post1_.[Flag] = 1 /* @p1 */ > and post1_.[MailState] = 0 /* @p2 */) > or (postreader0_.[ReceiveUser] = 'admin' /* @p3 */ > and post1_.[Flag] = 0 /* @p4 */ > and post1_.[MailState] = 0 /* @p5 */) > linq nhibernate orm > > -- > You received this message because you are subscribed to the Google Groups > "nhusers" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/nhusers?hl=en. > > -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
