public RootFolderService(IBasicRepository<RootFolder> rootFolderRepository,
                          IDiskProvider diskProvider,
                          ISeriesRepository seriesRepository,
                          IConfigService configService)
 {
     _rootFolderRepository = rootFolderRepository;
     _diskProvider = diskProvider;
     _seriesRepository = seriesRepository;
     _configService = configService;
 }
Beispiel #2
0
        public static async Task EnsureCollectionLoadedAsync <TEntity, TKey, TProperty>(
            this IBasicRepository <TEntity, TKey> repository,
            TEntity entity,
            Expression <Func <TEntity, IEnumerable <TProperty> > > propertyExpression,
            CancellationToken cancellationToken = default
            )
            where TEntity : class, IEntity <TKey>
            where TProperty : class
        {
            var repo = ProxyHelper.UnProxy(repository) as ISupportsExplicitLoading <TEntity, TKey>;

            if (repo != null)
            {
                await repo.EnsureCollectionLoadedAsync(entity, propertyExpression, cancellationToken).ConfigureAwait(false);
            }
        }
Beispiel #3
0
        private static async Task HardDeleteWithUnitOfWorkAsync <TEntity>(
            IBasicRepository <TEntity> repository,
            TEntity entity,
            bool autoSave,
            CancellationToken cancellationToken, IUnitOfWork currentUow
            )
            where TEntity : class, IEntity, ISoftDelete
        {
            var hardDeleteEntities = (HashSet <IEntity>)currentUow.Items.GetOrAdd(
                UnitOfWorkItemNames.HardDeletedEntities,
                () => new HashSet <IEntity>()
                );

            hardDeleteEntities.Add(entity);
            await repository.DeleteAsync(entity, autoSave, cancellationToken);
        }
Beispiel #4
0
 public BaseQueryType(IBasicRepository <TSet> repo, ISessionWrapper session)
 {
     Field(
         type: typeof(TSetType),
         name: nameof(repo.QueryData),
         description: SystemCP.DESC_QueryData,
         arguments: new QueryArguments(new QueryArgument <ListGraphType <IdGraphType> > {
         Name = SystemCP.KeyVal, Description = SystemCP.DESC_KeyVal
     }, new QueryArgument <NonNullGraphType <StringGraphType> > {
         Name = SystemCP.JWT, Description = SystemCP.DESC_JWT
     }),
         resolve: context =>
     {
         object[] keyVal = (context.GetArgument <object>(SystemCP.KeyVal) as List <object>).ToArray();
         if (!BaseOperateComm <TSet> .CheckAuthority(context, session, repo, FuncAction.Query, keyVal))
         {
             return(default);
    private static IUnitOfWorkManager GetUnitOfWorkManager<TEntity>(
        this IBasicRepository<TEntity> repository,
        [CallerMemberName] string callingMethodName = nameof(GetUnitOfWorkManager)
    )
        where TEntity : class, IEntity
    {
        if (ProxyHelper.UnProxy(repository) is not IUnitOfWorkManagerAccessor unitOfWorkManagerAccessor)
        {
            throw new AbpException($"The given repository (of type {repository.GetType().AssemblyQualifiedName}) should implement the " +
                $"{typeof(IUnitOfWorkManagerAccessor).AssemblyQualifiedName} interface in order to invoke the {callingMethodName} method!");
        }

        if (unitOfWorkManagerAccessor.UnitOfWorkManager == null)
        {
            throw new AbpException($"{nameof(unitOfWorkManagerAccessor.UnitOfWorkManager)} property of the given {nameof(repository)} object is null!");
        }

        return unitOfWorkManagerAccessor.UnitOfWorkManager;
    }
Beispiel #6
0
        public SongsController(IFreeSql fsql,
                               GuidRepository <Song> repos1,
                               GuidRepository <xxxx> repos2,

                               DefaultRepository <Song, int> repos11,
                               DefaultRepository <xxxx, int> repos21,

                               BaseRepository <Song> repos3, BaseRepository <Song, int> repos4,
                               IBasicRepository <Song> repos31, IBasicRepository <Song, int> repos41,
                               IReadOnlyRepository <Song> repos311, IReadOnlyRepository <Song, int> repos411
                               )
        {
            _songRepository = repos4;

            //test code
            var curd1 = fsql.GetRepository <Song, int>();
            var curd2 = fsql.GetRepository <Song, string>();
            var curd3 = fsql.GetRepository <Song, Guid>();
            var curd4 = fsql.GetGuidRepository <Song>();
        }
    public async static Task HardDeleteAsync<TEntity>(
        this IBasicRepository<TEntity> repository,
        IEnumerable<TEntity> entities,
        bool autoSave = false,
        CancellationToken cancellationToken = default
    )
        where TEntity : class, IEntity, ISoftDelete
    {
        var uowManager = repository.GetUnitOfWorkManager();

        if (uowManager.Current == null)
        {
            using (var uow = uowManager.Begin())
            {
                await HardDeleteWithUnitOfWorkAsync(repository, entities, autoSave, cancellationToken, uowManager.Current);
                await uow.CompleteAsync(cancellationToken);
            }
        }
        else
        {
            await HardDeleteWithUnitOfWorkAsync(repository, entities, autoSave, cancellationToken, uowManager.Current);
        }
    }
Beispiel #8
0
 public Transaction_Tests()
 {
     _personRepository  = GetRequiredService <IBasicRepository <Person, Guid> >();
     _unitOfWorkManager = GetRequiredService <IUnitOfWorkManager>();
 }
Beispiel #9
0
 public Transaction_Tests()
 {
     _personRepository  = ServiceProvider.GetRequiredService <IBasicRepository <Person, Guid> >();
     _bookRepository    = ServiceProvider.GetRequiredService <IBasicRepository <BookInSecondDbContext, Guid> >();
     _unitOfWorkManager = ServiceProvider.GetRequiredService <IUnitOfWorkManager>();
 }
Beispiel #10
0
 /// <summary>
 /// Creates a new instance of the <see cref="QueryController"/>.
 /// </summary>
 /// <param name="repository">The <see cref="IBasicRepository{Employee}"/> repository to use.</param>
 /// <param name="serviceProvider">The <see cref="IServiceProvider"/> for dependency resolution.</param>
 public QueryController(IBasicRepository <Employee> repository, IServiceProvider serviceProvider)
 {
     _repository      = repository;
     _serviceProvider = serviceProvider;
 }
Beispiel #11
0
        public static IEnumerable <TParent> LoadSubtype <TParent, TChild>(this IEnumerable <TParent> parents, Func <TParent, int> foreignKeySelector, IBasicRepository <TChild> childRepository)
            where TChild : ModelBase, new()
            where TParent : RestResource
        {
            var parentList = parents.Where(p => foreignKeySelector(p) != 0).ToList();

            if (!parentList.Any())
            {
                return(parents);
            }

            var ids             = parentList.Select(foreignKeySelector).Distinct();
            var childDictionary = childRepository.Get(ids).ToDictionary(child => child.Id, child => child);

            var childSetter = GetChildSetter <TParent, TChild>();

            foreach (var episode in parentList)
            {
                childSetter.Invoke(episode, new object[] { childDictionary[foreignKeySelector(episode)] });
            }

            return(parents);
        }
Beispiel #12
0
 internal static TEntity FoundEntity <TEntity>(this IBasicRepository <TEntity, Guid> repo) where TEntity : BaseEntity
 {
     return(repo.FoundEntity(Guid.NewGuid()));
 }
Beispiel #13
0
 public CalculationController(IBasicRepository <Calculation> repository, IServiceProvider serviceProvider)
 {
     _repository      = repository;
     _serviceProvider = serviceProvider;
 }
Beispiel #14
0
        public static IMongoDbRepository <TEntity, TKey> ToMongoDbRepository <TEntity, TKey>(this IBasicRepository <TEntity, TKey> repository)
            where TEntity : class, IEntity <TKey>
        {
            var mongoDbRepository = repository as IMongoDbRepository <TEntity, TKey>;

            if (mongoDbRepository == null)
            {
                throw new ArgumentException("Given repository does not implement " + typeof(IMongoDbRepository <TEntity, TKey>).AssemblyQualifiedName, nameof(repository));
            }

            return(mongoDbRepository);
        }
Beispiel #15
0
 public static Task <IMemoryDatabase> GetDatabaseAsync <TEntity, TKey>(this IBasicRepository <TEntity, TKey> repository)
     where TEntity : class, IEntity <TKey>
 {
     return(repository.ToMemoryDbRepository().GetDatabaseAsync());
 }
 public NamingConfigService(IBasicRepository<NamingConfig> repository)
 {
     _repository = repository;
 }
Beispiel #17
0
 public static Task <IMongoCollection <TEntity> > GetCollectionAsync <TEntity, TKey>(this IBasicRepository <TEntity, TKey> repository)
     where TEntity : class, IEntity <TKey>
 {
     return(repository.ToMongoDbRepository().GetCollectionAsync());
 }
 public BasicViewModel(IBasicRepository repository) : base(repository)
 {
 }
 /// <summary>
 /// Creates a new instance of the <see cref="QueryController"/>.
 /// </summary>
 /// <param name="repo">The <see cref="IBasicRepository{Contact}"/> repo to use.</param>
 /// <param name="provider">The <see cref="IServiceProvider"/> for dependency resolution.</param>
 public QueryController(IBasicRepository <Contact> repo,
                        IServiceProvider provider)
 {
     _repo            = repo;
     _serviceProvider = provider;
 }
 public CreateCalculationTests(IBasicRepository <Calculation> calculationRepository, UnitOfWork <FilippSystemContext, Calculation> unitOfWork)
 {
     _contextOptions = new DbContextOptionsBuilder <FilippSystemContext>()
                       .UseSqlite("Filename=Calculation-Test.db").Options;
     _unitOfWork = unitOfWork;
 }
Beispiel #21
0
 public static IMongoDatabase GetDatabase <TEntity, TKey>(this IBasicRepository <TEntity, TKey> repository)
     where TEntity : class, IEntity <TKey>
 {
     return(repository.ToMongoDbRepository().Database);
 }
 public TestDataBuilder(IBasicRepository <Person, Guid> personRepository)
 {
     _personRepository = personRepository;
 }
Beispiel #23
0
 public static IMongoCollection <TEntity> GetCollection <TEntity, TKey>(this IBasicRepository <TEntity, TKey> repository)
     where TEntity : class, IEntity <TKey>
 {
     return(repository.ToMongoDbRepository().Collection);
 }
Beispiel #24
0
 public BaseSchema(IBasicRepository <TSet> repo, ISessionWrapper session) : base()
 {
     Query = LibData.Build <TQuery>()(new object[] { repo, session }) as IObjectGraphType;
 }
Beispiel #25
0
 public static Task <IMongoQueryable <TEntity> > GetMongoQueryableAsync <TEntity, TKey>(this IBasicRepository <TEntity, TKey> repository)
     where TEntity : class, IEntity <TKey>
 {
     return(repository.ToMongoDbRepository().GetMongoQueryableAsync());
 }
Beispiel #26
0
 public FunnyController(IBasicRepository repository)
 {
     _repo = repository;
 }
Beispiel #27
0
 /// <summary>
 ///
 /// </summary>
 /// <typeparam name="TEntity"></typeparam>
 /// <typeparam name="TKey"></typeparam>
 /// <param name="repository"></param>
 /// <returns></returns>
 public static DbContext GetDbContext <TEntity, TKey>(this IBasicRepository <TEntity, TKey> repository)
     where TEntity : class, IEntity <TKey>
 {
     return(repository.ToEfCoreRepository().DbContext);
 }
Beispiel #28
0
 public DbContext_Replace_Tests()
 {
     _dummyRepository   = ServiceProvider.GetRequiredService <IBasicRepository <ThirdDbContextDummyEntity, Guid> >();
     _unitOfWorkManager = ServiceProvider.GetRequiredService <IUnitOfWorkManager>();
 }
 public SecondContextTestDataBuilder(IBasicRepository <BookInSecondDbContext, Guid> bookRepository, IGuidGenerator guidGenerator)
 {
     _bookRepository = bookRepository;
     _guidGenerator  = guidGenerator;
 }
Beispiel #30
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <typeparam name="TKey"></typeparam>
        /// <param name="repository"></param>
        /// <returns></returns>
        public static IEfCoreRepository <TEntity, TKey> ToEfCoreRepository <TEntity, TKey>(this IBasicRepository <TEntity, TKey> repository)
            where TEntity : class, IEntity <TKey>
        {
            if (!(repository is IEfCoreRepository <TEntity, TKey> efCoreRepository))
            {
                throw new ArgumentException("Given repository does not implement " + typeof(IEfCoreRepository <TEntity, TKey>).AssemblyQualifiedName, nameof(repository));
            }

            return(efCoreRepository);
        }
Beispiel #31
0
 public NewsController(IBasicRepository repo)
 {
     _repo = repo;
 }
Beispiel #32
0
 public BasicService(IBasicRepository <T> repository)
 {
     _repo = repository;
 }