このエラーが何であるかは知っていますが、私の質問は少し異なります。
これは、これらの脳の衰退の瞬間の1つです。
Repositoy と Unit of Work パターンに関する次の興味深い記事を読んでいます。
私はこのコードをいじっていますが、DIでIoCを使用できるように調整しようとしています。
さて、ここで私は精神的な空白にぶつかったところです。
インターフェイスなどを使用するようにすべてのクラスを変更しています。したがって、次のコード スニペットが与えられます。
public class UnitOfWork : IDisposable
{
private SchoolContext context = new SchoolContext();
private GenericRepository<Department> departmentRepository;
private GenericRepository<Course> courseRepository;
public GenericRepository<Department> DepartmentRepository
{
get
{
if (this.departmentRepository == null)
{
this.departmentRepository = new GenericRepository<Department>(context);
}
return departmentRepository;
}
}
}
}
この行を編集するにはどうすればよいですか:
this.departmentRepository = new GenericRepository<Department>(context);
したがって、実際のクラスを参照する必要がないため、クラスが分離されていることを確認して、構文エラーの発生を回避できます。
Cannot create an instance of the abstract class or interface interface with type
よろしくお願いします!