Ejemplo n.º 1
0
        public async Task <QueryResultDto <VehicleDto> > GetVehicles(VehicleQueryDto filterDto)
        {
            var filter      = mapper.Map <VehicleQueryDto, VehicleQuery>(filterDto);
            var queryResult = await repository.GetVehicles(filter);

            return(mapper.Map <QueryResult <Vehicle>, QueryResultDto <VehicleDto> >(queryResult));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <QueryResultDto <VehicleDto> > > GetVehicles(VehicleQueryDto queryDto)
        {
            var queryObj    = _mapper.Map <VehicleQueryDto, VehicleQuery>(queryDto);
            var queryResult = await _repository.GetVehiclesAsync(queryObj);

            return(Ok(_mapper.Map <QueryResultDto <VehicleDto> >(queryResult)));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult <QueryResultDto <VehicleDto> > > GetVehicles([FromQuery] VehicleQueryDto filterDto)
        {
            var filter   = _mapper.Map <VehicleQuery>(filterDto);
            var vehicles = await _repo.GetVehicles(filter);//_context.Vehicles.Include(x => x.Features);

            return(Ok(vehicles));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 多表连接,动态查询条件
        /// </summary>
        public void ManyTableDynamicCondition()
        {
            var query = new VehicleQueryDto();

            query.CarNo = "9";
            var filter = QueryExpression.CreateExpression <VehicleInfoDto, VehicleQueryDto>(query);
            var rep    = (IVehicleRegistRepository)this.uw.GetRepository(typeof(IVehicleRegistRepository));
            int count;
            var lst = rep.GetInfoList(filter, 10, 1, out count);
        }
Ejemplo n.º 5
0
        public async Task <PopularResult <byte[]> > GetBytesAsync(VehicleQueryDto dto)
        {
            var result = new PopularResult <byte[]>();

            var queryable = _vehicleRepository.Where(x => x.IsDelete == dto.IsDelete)
                            .WhereIf(!dto.License.IsNullOrWhiteSpace(), vehicle => vehicle.License.Contains(dto.License))
                            .WhereIf(!dto.Vin.IsNullOrWhiteSpace(), vehicle => vehicle.Vin.Contains(dto.Vin))
                            .WhereIf(dto.UnitId.HasValue, vehicle => vehicle.UnitId == dto.UnitId);

            var query = from v in queryable.PageBy(dto.SkipCount, dto.MaxResultCount)
                        join
                        u in _unitRepository.WhereIf(dto.UnitId.HasValue, unit => unit.Id == dto.UnitId)
                        on v.UnitId equals u.Id
                        into cls
                        from c in cls.DefaultIfEmpty()
                        select new VehicleEntity(v.Id)
            {
                License = v.License,
                //IsDelete = v.IsDelete,
                InteriorCode   = v.InteriorCode,
                EngineNo       = v.EngineNo,
                ActivationTime = v.ActivationTime,
                Color          = v.Color,
                CreateTime     = v.CreateTime,
                Creator        = v.Creator,
                Displacement   = v.Displacement,
                Price          = v.Price,
                PurchaseDate   = v.PurchaseDate,
                Purpose        = v.Purpose,
                Remark         = v.Remark,
                UnitId         = v.UnitId,
                VehicleType    = v.VehicleType,
                Vin            = v.Vin,
                Unit           = c
            };

            var vehicles = await Task.FromResult(query.ToList());

            //转换为导出对象
            var dtos = ObjectMapper.Map <List <VehicleEntity>, List <VehicleDto> >(vehicles);

            var stream = EPPlusHelper.GetMemoryStream(dtos);

            result.Success(stream.ToArray());

            return(result);
        }