Exemplo n.º 1
0
        private IList <T> InnerDoQuery(RestrictionBuilderBase restrictionBuilder, OrderByBuilder orderByBuilder, int max, int skip)
        {
            ArchiveExecutionContext executionContext = _archiveExecutionContextProvider.Get();

            if (executionContext == null)
            {
                throw new InvalidOperationException(nameof(executionContext) + " not set, cannot be null");
            }

            ArchiveQueryParameters context = new ArchiveQueryParameters();

            context.ArchiveName      = executionContext.ArchiveName;
            context.Entities         = executionContext.Entities;
            context.RequestedColumns = DynamicPropertyHelper.GetAllDbColumnsPrefixed <T>();
            int page = 0;

            if (skip > 0)
            {
                page = SetPageSizeAndGetPage(skip, max, context);
            }
            if (restrictionBuilder != null)
            {
                context.Restrictions = restrictionBuilder.GetRestrictions();
            }
            if (orderByBuilder != null)
            {
                context.OrderBy = orderByBuilder.Get();
            }

            return(_resultParser.Parse <T>(executionContext, _executor.GetItems(context, max, page)));
        }
Exemplo n.º 2
0
        public void TestAddOrder()
        {
            var ob = new OrderByBuilder();

            ob.AddOrder("contact.name", true);
            ob.AddOrder("contact.id", false);

            List <ArchiveOrderByInfo> result = ob.Get();

            Assert.Equal("contact.name", result[0].Name);
            Assert.Equal("contact.id", result[1].Name);
            Assert.Equal(OrderBySortType.ASC, result[0].Direction);
            Assert.Equal(OrderBySortType.DESC, result[1].Direction);
        }
Exemplo n.º 3
0
        public void TestAddOrderGeneric()
        {
            var ob = new OrderByBuilder();

            ob.AddOrder <TestPerson>("name", true);
            ob.AddOrder <TestPerson>("id", false);

            List <ArchiveOrderByInfo> result = ob.Get();

            Assert.Equal("testperson.name", result[0].Name);
            Assert.Equal("testperson.id", result[1].Name);
            Assert.Equal(OrderBySortType.ASC, result[0].Direction);
            Assert.Equal(OrderBySortType.DESC, result[1].Direction);
        }