title: how to execute custom function for each item later using linq deferred execution?
body: <p>I have a:</p>
  
  <pre><code>public Dictionary&lt;string,BaseModel&gt; data  { get; set; }
  </code></pre>
  
  <p>and I would like to achieve the equivalent of this code which I have working now, only using Linq deferred execution.</p>
  
  <pre><code>foreach (KeyValuePair&lt;string, BaseModel&gt; item in data)
  {
     T model = (T)item.Value; //each item needs to be cast to T, T inherits from BaseModel
     model.Init(this, personId); //Init is a function I wrote I want to call on each item
     l.Add(model); //currently I am adding each item to a list, but IEnumerable&lt;T&gt; can work
  }
  </code></pre>
  
  <p>I started writing code like:</p>
  
  <pre><code>IEnumerable&lt;T&gt; l = Cache[type].Data.Cast&lt;T&gt;()
                                     .Select(item =&gt; item);
  </code></pre>
  
  <p>but I can't figure out how to call the Init function (each model has one, they all inherit from BaseModel) on every item. I have been reading about predicate delegates and the like but can't find an example of how to do something like (pseduocode):</p>
  
  <pre><code>IEnumerable&lt;T&gt; l = Cache[type].Data.Cast&lt;T&gt;()
                                     .Select(item =&gt; item)
                                     .RunMeOnEachItemLater(InitWrapperDelegate);
  </code></pre>
  
  <p>In case you are wondering what this is for, I have an MVC project and I am implementing a model data cache. </p>