I have two classes derived from BankAccount class – FixedBankAccount and SavingsBankAccount. This is working based on “TPH (Table Per Hierarchy)” with LINQ to SQL.
[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
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:
The type or namespace name 'param' could not be found”
with the following code (which uses “OfType” on LINQ query)
How can we make it working?
Repository:
namespace RepositoryLayer
{
public class LijosSimpleBankRepository : ILijosBankRepository
{
public System.Data.Linq.DataContext Context { get; set; }
public virtual List<DBML_Project.BankAccount> GetAllAccountsOfType(DBML_Project.BankAccount param)
{
var query = from p in Context.GetTable<DBML_Project.BankAccount>().OfType<param>()
select p;
}
}
}