开发者

parsing expression trees with booleans

开发者 https://www.devze.com 2022-12-28 20:50 出处:网络
I am trying to parse an expression tree for a linq provider and running into a little snag with booleans.

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

I can parse thi开发者_如何学编程s 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.


Hope this helps,

The first one has expression tree as shown below.

RETURN ( Binary Expression (MemberAccess, Constant) )

The second one has expression tree as shown below.

RETURN ( MemberAccess )

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号