IUnitOfWork
Rather than Querable IDbSet, we should send back the Entity Specific Repository object.
Sending Queryable IDbSet cause the Persisence Logic or Querying logic leaked into the Controller
or Services.
Application Specific UOW Class & Interfaces Samples
Its name should be IUnitOfWork.cs
namespace CleanArchitecture.Application.Interfaces
{
public interface IDatabaseService/IUnitOfWork
{
IDbSet<Customer> Customers { get; set; }
IDbSet<Employee> Employees { get; set; }
IDbSet<Product> Products { get; set; }
IDbSet<Sale> Sales { get; set; }
void Save();
}
}
using GigHub.Core.Dtos;
using GigHub.Core.Repositories;
namespace GigHub.Core
{
public interface IUnitOfWork
{
IGigRepository Gigs { get; }
IAttendanceRepository Attendances { get; }
IGenreRepository Genres { get; }
IFollowingRepository Followings { get; }
IApplicationUserRepository Users { get; }
INotificationRepository Notifications { get; }
IUserNotificationRepository UserNotifications { get; }
void Complete();
}
}
Sending Queryable IDbSet cause the Persisence Logic or Querying logic leaked into the Controller
or Services.
Application Specific UOW Class & Interfaces Samples
Its name should be IUnitOfWork.cs
namespace CleanArchitecture.Application.Interfaces
{
public interface IDatabaseService/IUnitOfWork
{
IDbSet<Customer> Customers { get; set; }
IDbSet<Employee> Employees { get; set; }
IDbSet<Product> Products { get; set; }
IDbSet<Sale> Sales { get; set; }
void Save();
}
}
using GigHub.Core.Dtos;
using GigHub.Core.Repositories;
namespace GigHub.Core
{
public interface IUnitOfWork
{
IGigRepository Gigs { get; }
IAttendanceRepository Attendances { get; }
IGenreRepository Genres { get; }
IFollowingRepository Followings { get; }
IApplicationUserRepository Users { get; }
INotificationRepository Notifications { get; }
IUserNotificationRepository UserNotifications { get; }
void Complete();
}
}
Comments
Post a Comment