Example #1
0
        public ProductCollectionInfo Get(int pageNumber, int pageSize)
        {
            try
            {
                var products       = _commonDb.Query <ProductWithDescription>($"select * from ({SubQuery}) subQuery order by code offset {pageNumber * pageSize - pageSize} rows fetch next {pageSize} rows only");
                var collectionInfo = new ProductCollectionInfo();
                _commonDb.GetPageCount(pageSize, "select count(1) from products", collectionInfo);
                collectionInfo.Entities = products;

                return(collectionInfo);
            }
            catch (Exception e)
            {
                throw new ProductOperationException($"Products get error!", e);
            }
        }
Example #2
0
        public IEntityCollectionInfo <Product> GetEntityCollectionInfo(int pageNumber, int pageSize)
        {
            var collectionInfo = new ProductCollectionInfo();

            collectionInfo.Entities = _commonDb.Query <Product>($"select * from products order by id offset {pageNumber * pageSize - pageSize} rows fetch next {pageSize} rows only");
            _commonDb.GetPageCount(pageSize, "select count(1) from products", collectionInfo);

            return(collectionInfo);
        }
Example #3
0
        public IEntityCollectionInfo <MenuOnDay> GetEntityCollectionInfo(int pageNumber, int pageSize)
        {
            var collectionInfo = new MenuOnDayCollectionInfo();

            collectionInfo.Entities = _commonDb.Query <MenuOnDay>($"select * from MenuOnDay order by date desc offset {pageNumber * pageSize - pageSize} rows fetch next {pageSize} rows only");
            _commonDb.GetPageCount(pageSize, "select count(1) from MenuOnDay", collectionInfo);

            return(collectionInfo);
        }
Example #4
0
        public IEntityCollectionInfo <Dish> GetEntityCollectionInfo(int pageNumber, int pageSize)
        {
            var collectionInfo = new DishCollectionInfo();

            collectionInfo.Entities = _commonDb.Query <Dish>(
                $"select * from Dish order by d.Id offset {pageNumber * pageSize - pageSize} rows fetch next {pageSize} rows.only");

            _commonDb.GetPageCount(pageSize, "select count(1) from Dish", collectionInfo);

            return(collectionInfo);
        }
        public UnitCollectionInfo Get(int pageNumber, int pageSize)
        {
            try
            {
                var collectionInfo = new UnitCollectionInfo();
                collectionInfo.Entities = _commonDb.Query <ProductUnit>($"select * from units order by code offset {pageNumber*pageSize-pageSize} rows fetch next {pageSize} rows only");

                _commonDb.GetPageCount(pageSize, "select count(1) from units", collectionInfo);
                return(collectionInfo);
            }
            catch (Exception e)
            {
                throw new ProductUnitOperationException($"Units get error!", e);
            }
        }
Example #6
0
        public CategoryCollectionInfo Get(int pageNumber, int pageSize)
        {
            try
            {
                var collectionInfo = new CategoryCollectionInfo();
                var query          = $"select * from categories order by code offset {pageNumber * pageSize - pageSize} rows fetch next {pageSize} rows only";
                collectionInfo.Entities = _commonDb.Query <ProductCategory>(query);
                _commonDb.GetPageCount(pageSize, $"select count(1) from categories", collectionInfo);

                return(collectionInfo);
            }
            catch (Exception e)
            {
                throw new CategoryOperationException($"Categories get error!", e);
            }
        }