public ReaderDomainService(IRepositoryWithEntity <Core.Model.Reader> readerRepositoryWithEntity, IRepositoryWithTEntityAndTPrimaryKey <Book, string> bookRepository, IRepositoryWithTEntityAndTPrimaryKey <BookHistory, string> bookHistoryRepository) { _readerRepository = readerRepositoryWithEntity; _bookRepository = bookRepository; _bookHistoryRepository = bookHistoryRepository; }
public static IQueryable <TEntity> AsNoTracking <TEntity, TPrimaryKey>(this IRepositoryWithTEntityAndTPrimaryKey <TEntity, TPrimaryKey> repository) where TEntity : class, IAggregateRoot <TPrimaryKey> { var sets = repository.GetAll().As <DbSet <TEntity> >(); if (sets == null) { throw new ArgumentException(); } return(sets.AsNoTracking()); }
public static DbContext GetDbContext <TEntity, TPrimaryKey>(this IRepositoryWithTEntityAndTPrimaryKey <TEntity, TPrimaryKey> repository) where TEntity : class, IAggregateRoot <TPrimaryKey> { var repositoryWithDbContext = ProxyHelper.UnProxy(repository) as IRepositoryWithDbContext; if (repositoryWithDbContext != null) { return(repositoryWithDbContext.GetDbContext()); } throw new ArgumentException("Given repository does not implement IRepositoryWithDbContext", nameof(repository)); }
public UserAppService(IRepositoryWithTEntityAndTPrimaryKey <Domain.Core.Model.User, long> userRepository) { _userRepository = userRepository; }
public static void DetachFromDbContext <TEntity, TPrimaryKey>(this IRepositoryWithTEntityAndTPrimaryKey <TEntity, TPrimaryKey> repository, TEntity entity) where TEntity : class, IAggregateRoot <TPrimaryKey> { repository.GetDbContext().Entry(entity).State = EntityState.Detached; }