Linq: Add support for bitwise And, Or operators

Description

When I create linq query that use AND operator (&) like below i get InvalidCastException:

session.Query<Person>().Where(p => p.Name.Contains("Jo") & p.Address.Contains("War")).ToArray();

My current workaround is to use AndAlso operator (&&).

The issue can be related to NH-2539, because exception is throwed in the same place in AsBooleanExpression method.

Environment

None

Attachments

1

is duplicated by

Activity

Show:

Alex Zaytsev 
October 31, 2016 at 8:42 PM
(edited)

~PR is ready for review: https://github.com/nhibernate/nhibernate-core/pull/516 ~ The changes for this issue has been removed from the PR

SR 
July 19, 2012 at 4:48 PM

In my case there was no reason. I just have Filter extension method that dynamically build expression for Where method and it use Expression.And method instead of Expression.AndAlso - that method works great with Entity Framework, but when I use it with NHibernate it doesn't work so I changed it.

Alex Zaytsev 
July 19, 2012 at 4:31 PM

What is the reasont to use & operator?

SR 
July 19, 2012 at 4:08 PM

Test case

Details

Assignee

Reporter

Labels

Components

Affects versions

Priority

Who's Looking?

Open Who's Looking?
Created July 19, 2012 at 4:05 PM
Updated August 10, 2021 at 9:08 PM
Who's Looking?