On an MVC / Entity Framework project I am moving away from the Repository pattern.
First, it has given me a few problemas ... And I think DBContext and IDBset kind of implement UnitOfWork and Repository.
So I am starting to use commands and queries. Here is an example:
public class ListPostsQuery {
public ListPostsQuery() {
}
public List<Post> Execute(int currentPage, int pageSize) {
}
}
How should I integrate or inject DBContext in my Queries / Commands?
Maybe using a wrapper for DBContext with Save method and exposing the sets?
Or should I just create a new context in Execute method?
public List<Post> Execute(int currentPage, int pageSize) {
using (Context = new DBContext) {
}
}
Could someone, please, advice me on this?