views:

87

answers:

1

I am trying to parse an expression tree for a linq provider and running into a little snag with booleans.

I can parse this no problems.

var p = products.Where(x=>x.IsAvailable == true).ToList();

however when its written like this?

var p = products.Where(x=>x.IsAvailable).ToList();

i only get a MemberAccess to look at and i can't see how i deduce that it is true or false (!x.IsAvailable). Any help would be great.

Thanks.

+1  A: 

Hope this helps,

The first one has expression tree as below..

RETURN ( Binary Expression (MemberAccess, Constant) )

The second one has expression tree as below..

RETURN ( MemberAccess )

Since member is of type boolean, its value determines state of execution.

Akash Kava