title: Generic LINQ function - SelectMany with selection Func as a parameter
body: <p>I've got a class with many string arrays. I'd like to have one generic function which can get me a unique <code>List&lt;string&gt;</code> for a given property. Example:</p>
  
  <pre><code>public class Zoo 
  {    
    string Name { get; set;}
    string[] Animals { get; set;}
    string[] Zookeepers { get; set;}
    string[] Vendors { get; set;}
  }
  </code></pre>
  
  <p>I'd like to have a generic function that will get me a distinct <code>List&lt;string&gt;</code> of Animals in List? I want this to be generic, so I can also get a distinct list of Zookeepers and Vendors.</p>
  
  <p>I've been trying this, but it doesn't compile:</p>
  
  <pre><code>public static List&lt;string&gt; GetExtendedList(Func&lt;Zoo, string[]&gt; filter)
  {
          var Zoos = QueryZoos(HttpContext.Current);
          return Zoos.Where(z =&gt; z.Type == "Active")
              .SelectMany(filter)
              .Distinct()
              .OrderBy(s =&gt; s);
      }
  </code></pre>
  
  <p>Note: this is related to two questions I've asked before, but I'm having trouble merging the information. I previously asked <a href="https://stackoverflow.com/questions/1229897/linq-select-all-children-from-an-object-hierarchy">how to query using SelectMany (SO 1229897)</a> and separately asked how to write a generic function which <a href="https://stackoverflow.com/questions/1278989/how-can-i-set-linq-selectmany-projection-via-func-parameter">gets a list using Select rather than SelectMany (SO 1278989)</a>.</p>