title: C# define LET in LINQ
body: <p>I have multiple LINQ queries that uses the same LET variables, I would like to predefine these somehow.</p>
  
  <pre><code>IQueryable&lt;RouteQueryModel&gt; query =
      (from b in db.routes
       let avg_rating = b.ratings.Any() ? 
           b.ratings.Select(r =&gt; r.rating1).Average() : 
           0
       let distance_to_first_from_me = b.coordinates.
           Select(c =&gt; c.position).
           FirstOrDefault().
           Distance(DbGeography.FromText(currentLocation, 4326))
       let distance_to_last_from_me = b.coordinates.
           OrderByDescending(c =&gt; c.sequence).
           Select(d =&gt; d.position).
           FirstOrDefault().
           Distance(DbGeography.FromText(currentLocation, 4326))
       let distance_to_from_me = distance_to_first_from_me &lt; distance_to_last_from_me ? 
           distance_to_first_from_me : 
           distance_to_last_from_me
       where b.endpoints.Any(e =&gt; values.Any(t =&gt; t == e.town.town_id))
       select new RouteQueryModel 
       { 
           b = b, 
           distance_to_from_me = distance_to_from_me.Value, 
           avg_rating = avg_rating
       }
   );
  </code></pre>
  
  <p>I'm using those three distance_to LETs in 8 different queries, is there any way to make a template for those that i can use in my queries?</p>