title: Calling a function within a Linq query
body: <p>If I want to iterate through a collection, and call a function on each element in the collection, I could go with :</p>
  
  <pre><code>foreach (var obj in objColl)
  {
      MyFunction(obj);
  }
  </code></pre>
  
  <p>Should I want to do this with linq, I can use either of those :</p>
  
  <pre><code>//#1
  var unused = (from var obj in objColl select MyFunction(obj)).ToList();
  
  //#2
  var unused = objColl.Select(obj =&gt; MyFunction(obj)).ToList();
  </code></pre>
  
  <p>I know this works, but it doesn't seem right. Of course, my actual cases are more complex queries that that, but it comes down to this since I could build my IQueryable with Linq and iterate through it and call the function.</p>
  
  <p>Edit:
  Here is one example of what I did. (Item# are things I can't disclose)</p>
  
  <pre><code>var dummyValue = (from
                    Item7 in dal.GetAgencyConvertions().Where(age =&gt; age.SourceName == "Item1" &amp;&amp; age.TargetName == "Item2")
                    join Item6 in dal.GetAgencyConvertions().Where(age =&gt; age.SourceName == "Item2" &amp;&amp; age.TargetName == "Item3") on Item6.TargetValue equals Item7.SourceValue
                    join agency in dal.GetAgencies() on Item7.SourceValue equals agency.Agency
                    orderby Item7.TargetValue
                    select vl.ValueListItems.Add(agency.ID, Item7.TargetValue)).ToList();
  </code></pre>