public async Task Dapper_Repository_Count_Should_Return_Correct_Value_For_Nullable_Int_Filter() { using (IUnitOfWorkCompleteHandle uow = _unitOfWorkManager.Begin()) { using (_unitOfWorkManager.Current.SetTenantId(AbpSession.TenantId)) { await _goodDapperRepository.InsertAsync(new Good { Name = "AbpTest" }); await _unitOfWorkManager.Current.SaveChangesAsync(); int?id = 1; var dapperCount = await _goodDapperRepository.CountAsync(a => a.Id != id && a.Name == "AbpTest"); dapperCount.ShouldBe(0); } uow.Complete(); } }
public async virtual Task <PagedResultDto <TEntityDto> > GetAll(TGetAllInput input) { Expression <Func <TEntity, bool> > expression = null; Tuple <Expression <Func <TEntity, object> >[], bool> sorting = null; int pageNumber = 0; int itemsPerPage = 0; int totalCount = 0; IEnumerable <TEntity> list = null; expression = ApplyFiltering(input); sorting = ApplySorting(input); var pageInput = input as IPagedResultRequest; if (pageInput != null) { pageNumber = pageInput.PageIndex - 1; if (pageNumber < 0) { pageNumber = 0; } itemsPerPage = pageInput.PageSize; list = await Repository.GetAllPagedAsync(expression, pageNumber, itemsPerPage, sorting.Item2, sorting.Item1); } else { list = await Repository.GetAllAsync(expression, sorting.Item2, sorting.Item1); } totalCount = await Repository.CountAsync(expression); return(new PagedResultDto <TEntityDto>(pageNumber, itemsPerPage, totalCount, MapToEntityDtoList(list.ToList()))); }