public async Task <QueryResult <IDictionary <string, object> > > QueryDefectTypeDynamic(
            DefectTypeQueryProjection projection,
            DefectTypeQueryOptions options,
            DefectTypeQueryFilter filter = null,
            DefectTypeQuerySort sort     = null,
            DefectTypeQueryPaging paging = null)
        {
            var query = DefectTypes;

            #region General
            if (filter != null)
            {
                query = query.Filter(filter);
            }
            query = query.Project(projection);
            int?totalCount = null;
            if (options.count_total)
            {
                totalCount = query.Count();
            }
            #endregion
            if (!options.single_only)
            {
                #region List query
                if (sort != null)
                {
                    query = query.Sort(sort);
                }
                if (paging != null && (!options.load_all || !DefectTypeQueryOptions.IsLoadAllAllowed))
                {
                    query = query.SelectPage(paging.page, paging.limit);
                }
                #endregion
            }

            if (options.single_only)
            {
                var single = query.SingleOrDefault();
                if (single == null)
                {
                    return(null);
                }
                var singleResult = GetDefectTypeDynamic(single, projection, options);
                return(new QueryResult <IDictionary <string, object> >()
                {
                    Single = singleResult
                });
            }
            var entities = query.ToList();
            var list     = GetDefectTypeDynamic(entities, projection, options);
            var result   = new QueryResult <IDictionary <string, object> >();
            result.List = list;
            if (options.count_total)
            {
                result.Count = totalCount;
            }
            return(result);
        }
 public ValidationData ValidateGetDefectTypes(
     ClaimsPrincipal principal,
     DefectTypeQueryFilter filter,
     DefectTypeQuerySort sort,
     DefectTypeQueryProjection projection,
     DefectTypeQueryPaging paging,
     DefectTypeQueryOptions options)
 {
     return(new ValidationData());
 }
        public async Task <IActionResult> Get([FromQuery][QueryObject] DefectTypeQueryFilter filter,
                                              [FromQuery] DefectTypeQuerySort sort,
                                              [FromQuery] DefectTypeQueryProjection projection,
                                              [FromQuery] DefectTypeQueryPaging paging,
                                              [FromQuery] DefectTypeQueryOptions options)
        {
            var validationData = _service.ValidateGetDefectTypes(
                User, filter, sort, projection, paging, options);

            if (!validationData.IsValid)
            {
                return(BadRequest(AppResult.FailValidation(data: validationData)));
            }
            var result = await _service.QueryDefectTypeDynamic(
                projection, options, filter, sort, paging);

            if (options.single_only && result == null)
            {
                return(NotFound(AppResult.NotFound()));
            }
            return(Ok(AppResult.Success(result)));
        }