示例#1
0
        public async Task <IActionResult> Product(int currentPage = 1)
        {
            //  var productCategory = await _context.ProductCategory.Include(x => x.Product).Include(x => x.Category).ToListAsync();
            ModelPaging productCategory = new ModelPaging(_context);

            productCategory.CurrentPage = currentPage;
            productCategory.Data        = await _context.ProductCategory.Include(x => x.Product).Include(x => x.Category).Skip(currentPage - 1).Take(1).ToListAsync();

            //  var dbShop = _context.Product.Include(p => p.MeasuringUnit);

            return(View(productCategory));
        }
        public async Task <ModelPaging> GetAll(int skip, int limit)
        {
            using (var conn = new SqlConnection(AppSettings.ConnectionString))
            {
                var sql    = Sql.SqlQueryCach["Model.All"];
                var result = (await conn.QueryAsync <Model.Model>(sql, new { skip = skip, limit = limit }))
                             .ToArray();
                var sqlc   = Sql.SqlQueryCach["Model.CountAll"];
                var count  = (await conn.QueryAsync <int>(sqlc)).FirstOrDefault();
                var output = new ModelPaging
                {
                    Data  = result,
                    Total = count
                };

                return(output);
            }
        }
        public async Task <ModelPaging> GetAll(int skip, int limit, string filter)
        {
            using (var conn = new SqlConnection(AppSettings.ConnectionString))
            {
                string sqlfilter, sql;
                CreateFilter(filter, out sqlfilter, out sql);
                var result = (await conn.QueryAsync <Model.Model>(sql, new { skip = skip, limit = limit }))
                             .ToArray();
                var sqlc   = $"{ModelCommon.sqlCountCommon} {sqlfilter}";
                var count  = (await conn.QueryAsync <int>(sqlc)).FirstOrDefault();
                var output = new ModelPaging
                {
                    Data  = result,
                    Total = count
                };

                return(output);
            }
        }