Kart
Kart

Reputation: 13

Convert LINQ query expression

I have the following code:

var attr = from a in ClsT.Current.GetValues()  
                   from b in a.SomeMethod()  
                   where typeof(ClsA).SomeOtherMethod(b)  
                   select b;

How can I convert it to => notation?

Upvotes: 0

Views: 155

Answers (3)

Stephen McDaniel
Stephen McDaniel

Reputation: 2968

The equivalent code would be:

var attr = ClsT.Current.GetValues()
           .SelectMany(a => a.SomeMethod())
           .Where(b => typeof(ClsA).SomeOtherMethod(b);

Upvotes: 1

Jamiec
Jamiec

Reputation: 136114

Perhaps:

ClsT.Current.GetValues().SomeMethod().Where(b => typeof(ClsA).SomeOtherMethod(b))

Upvotes: 0

Jens
Jens

Reputation: 25563

This would be

ClsT.Current.GetValues().SelectMany(a => a.SomeMethod())
                        .Where(b => typeof(ClsA).SomeOtherMethod(b));

Upvotes: 1

Related Questions