私は2つの基本クラスの間に関係があります:
public abstract class RecruiterBase<T>
{
// Properties declare here
// Constructors declared here
public abstract IQueryable<T> GetCandidates();
}
public abstract class CandidateBase<T>
{
// Properties declare here
// Constructors declared here
}
そして、その具体的な実装は次のとおりです。
public class CandidateA : CandidateBase<CandidateA>
{
// Constructors declared here
}
public class RecruiterA : RecruiterBase<RecruiterA>
{
// Constructors declared here
// ----HERE IS WHERE I AM BREAKING DOWN----
public override IQueryable<CandidateA> GetCandidates()
{
return from c in db.Candidates
where c.RecruiterId == this.RecruiterId
select new CandidateA
{
CandidateId = c.CandidateId,
CandidateName = c.CandidateName,
RecruiterId = c.RecruiterId
};
}
}
MSDN のドキュメント http://msdn.microsoft.com/en-us/library/ms379564%28VS.80%29.aspx (約半分下) および同様の (ただし同一ではない) クエストイン SO の戻り値の型を指定するサブクラスに従ったベースクラスからの抽象メソッド
オーバーライドされたメソッド GetCandidates の戻り値の型に concreate 実装を使用できますが、それは私が望むものではありません。別の抽象クラスの具象実装を使用したいと考えています。これは、データベースの親子関係です。私が達成しようとしていることは可能ですか?現在、GetCandidates の戻り値の型が一致しないというコンパイル時エラーが発生します。
ありがとう