Short-circuiting of boolean operators

Description

(not sure if this is really a bug or a feature request)

As far as I can tell, short-circuiting of boolean operators isn't supported/working. For example (just dummy code):

public IList<Person> GetFiltered(DateTime registrationDate, int? age)
{
return (from person in repository.Linq<Person>
where person.RegistrationDate == registrationDate &&
(age == null || person.Age == age.Value)
select person).ToList();
}

If "age" is NULL then I would expect that "age.Value" doesn't get called.

Actual situation is that "age.Value" gets called and throws.

Ideally I'd like for the short-circuiting to work and when age is NULL the other part of the expression doesn't get evaluated.

Or a workaround suggestion is also appreciated, but given the fact that a query might be much more complicated and involve several nullables.

Thanks

Environment

None

Activity

Details

Assignee

Reporter

Components

Affects versions

Priority

Who's Looking?

Open Who's Looking?
Created March 17, 2010 at 2:36 AM
Updated March 17, 2010 at 2:36 AM
Who's Looking?