Exemple #1
0
        public async Task <PagedData <CarListVm> > GetPagedDataAsync(CarSourcePagedRequest request)
        {
            StringBuilder sql = new StringBuilder();

            sql.AppendLine($@"select 
                        id car_id,brand_name,series_name,style_name,model_name,sales_price,
                        tag,image,status,user_id
                        from car where status != {1} ");
            string where = request.GenerateWhereSql();
            if (!string.IsNullOrWhiteSpace(where))
            {
                sql.AppendLine(" and " + where);
            }
            string orderBy = request.GenerateOrderBySql();

            if (string.IsNullOrWhiteSpace(orderBy))
            {
                sql.AppendLine("order by created_time desc");
            }
            else
            {
                sql.AppendLine(orderBy);
            }

            var carSources = await _dbContext.GetPagedDataAsync <CarListVm>(sql.ToString(), request, request.PageSize, request.PageNumber);

            return(carSources);
        }