BankAccount クラスから派生した 2 つのクラス、FixedBankAccount と SavingsBankAccount があります。これは、LINQ to SQL を使用した「TPH (Table Per Hierarchy)」に基づいて動作しています。
[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
すべての SavingsBankAccount (渡されたタイプが SavingsBankAccount の場合) または FixedBankAccounts (渡されたタイプが FixedBankAccount の場合) を返すメソッド GetAllAccountsOfType を実装する必要があります。エラーが発生しています:
タイプまたはネームスペース名「param」が見つかりませんでした」
次のコード (LINQ クエリで「OfType」を使用)
どうすればそれを機能させることができますか?
リポジトリ:
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;
}
}
}