After a long pause I have decided to do all my future posts in English.

In a λ expression, I had a need to call an arbitrary method within my expression.
Now istead of calling the method multiple times within the expression, I had a need to assign the result to a local variable.

Here is the result of how that is achieved.

   1:  var result = mylist.AsEnumerable().Where(x => x 
   2:                      { 
   3:                          var age = GetAge(f.Birthdate); 
   4:                          return age >= search.Age.From && 
   5:                          age <= search.Age.To; 
   6:                      })
   7:                      ).Select(p => new Person 
   8:                          { 
   9:                              Id = p.Id,  
  10:                              Name = p.Name
  11:                          }).ToList();

 

Instead of invoking 'GetAge' method twice, the 'age' variable is declared and the result of the 'GetAge' is assigned to 'age'. The 'age' variable can now be used within the λ expression.