Inheritance: System.Entity
Example #1
0
        public static UserQueryEntity ToUserQuery(this QueryRequest request, QueryDescription qd, QueryEntity query, Pagination defaultPagination, bool withoutFilters)
        {
            var tuple = SmartColumns(request.Columns, qd);

            var defaultMode = defaultPagination.GetMode();
            var defaultElementsPerPage = defaultPagination.GetElementsPerPage();

            var mode = request.Pagination.GetMode();
            var elementsPerPage = request.Pagination.GetElementsPerPage();

            bool isDefaultPaginate = defaultMode == mode && defaultElementsPerPage == elementsPerPage;

            return new UserQueryEntity
            {
                Query = query,
                WithoutFilters = withoutFilters,
                Owner = DefaultOwner(),
                Filters = withoutFilters ? new MList<QueryFilterEntity>() : request.Filters.Select(f => new QueryFilterEntity
                {
                    Token = new QueryTokenEntity(f.Token),
                    Operation = f.Operation,
                    ValueString = FilterValueConverter.ToString(f.Value, f.Token.Type)
                }).ToMList(),
                ColumnsMode = tuple.Item1,
                Columns = tuple.Item2,
                Orders = request.Orders.Select(oo => new QueryOrderEntity
                {
                    Token = new QueryTokenEntity(oo.Token),
                    OrderType = oo.OrderType
                }).ToMList(),
                PaginationMode = isDefaultPaginate ? (PaginationMode?)null : mode,
                ElementsPerPage = isDefaultPaginate ? (int?)null : elementsPerPage,
            };
        }
        public static Implementations? GetImplementations(QueryEntity query)
        {
            if (query == null)
                return null;

            var queryName = query?.ToQueryName();

            if (queryName == null)
                return null;

            var entityColumn = DynamicQueryManager.Current.QueryDescription(queryName).Columns.Single(a => a.IsEntity);
            var implementations = entityColumn.Implementations.Value;

            if (implementations.IsByAll)
                throw new InvalidOperationException("ByAll implementations not supported");

            return implementations;
        }