title: Using “OfType” in LINQ
body: <p>I have two classes derived from BankAccount class – FixedBankAccount and SavingsBankAccount. This is working based on “TPH (Table Per Hierarchy)” with LINQ to SQL. </p>
  
  <pre><code>[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.BankAccount")]
  [InheritanceMapping(Code = "Fixed", Type = typeof(FixedBankAccount), IsDefault = true)]
  [InheritanceMapping(Code = "Savings", Type = typeof(SavingsBankAccount))]
  public abstract partial class BankAccount : INotifyPropertyChanging, INotifyPropertyChanged
  </code></pre>
  
  <p>I need to implement a method GetAllAccountsOfType which will return all the SavingsBankAccount (if the type passed is SavingsBankAccount) or FixedBankAccounts (if the type passed is FixedBankAccount). I am getting error:</p>
  
  <blockquote>
    <p>The type or namespace name 'param' could not be found” </p>
  </blockquote>
  
  <p>with the following code (which uses “OfType” on LINQ query)</p>
  
  <p>How can we make it working?</p>
  
  <p>Repository:</p>
  
  <pre><code>namespace RepositoryLayer
  {    
      public class LijosSimpleBankRepository : ILijosBankRepository
      {
          public System.Data.Linq.DataContext Context { get; set; }
  
          public virtual List&lt;DBML_Project.BankAccount&gt; GetAllAccountsOfType(DBML_Project.BankAccount param)
          {
              var query = from p in Context.GetTable&lt;DBML_Project.BankAccount&gt;().OfType&lt;param&gt;()
                          select p;
          }
      }
  }
  </code></pre>