次のエラーが発生します。
エラー1
T
メソッド
' 'のタイプパラメータ''の制約は、インターフェイスメソッド''のタイプ パラメータ' 'genericstuff.Models.MyClass.GetCount<T>(string)
の制約と一致する必要があります。 代わりに、明示的なインターフェイスの実装を使用することを検討してください。T
genericstuff.IMyClass.GetCount<T>(string)
クラス:
public class MyClass : IMyClass
{
public int GetCount<T>(string filter)
where T : class
{
NorthwindEntities db = new NorthwindEntities();
return db.CreateObjectSet<T>().Where(filter).Count();
}
}
インターフェース:
public interface IMyClass
{
int GetCount<T>(string filter);
}