using UnitOfWork and Repository Pattern with Entity Framework

后端 未结 3 1082
情书的邮戳
情书的邮戳 2021-02-04 21:22

I\'m gonna to use repository and UnitOfwork in my data access layer to do this take a look at one contact aggregateroot

 public interface IAggregateRoot
    {
          


        
3条回答
  •  情深已故
    2021-02-04 22:00

    I agree with the Doctor, DbContext is already a UnitOfWork, and adding another UoW abstraction on top of it is typically redundant, unless you think it's highly likely you might switch database technologies in the future.

    I don't agree, however, with treating DbSet's as repositories, since this tightly couples your queries to the methods that use them. If you need to change a query, you have to do it everywhere you use it.

    I prefer to either use a stand-alone repository (or service interface, they serve similar functions) or to use more of a CQRS system for Command/Query Seperation, an use query objects.

提交回复
热议问题