dapper mysql 分页_Dapper存储过程分页

创建了用户表UserInfo、商品表Goods、购物车表ShopCar和订单表OrderInfo,定义了各表之间的外键关系,并提供了分页显示商品的存储过程sp_Show。此段代码主要涉及数据库设计与SQL操作。
摘要由CSDN通过智能技术生成

create database Month6

use Month6

--用户表

create table UserInfo

(

UId int primary key identity,

UName varchar(max), --登录名

UPwd varchar(max) --密码

)

--商品表

create table Goods

(

GId int primary key identity,

GName varchar(max),

GImg varchar(max),

GColor varchar(max),

GSize varchar(max),

GPrice int

)

select * from Goods

--购物车表

create table ShopCar

(

CId int primary key identity,

BuyCount int,

UId int foreign key references UserInfo(UId), --用户外键

GId int foreign key references Goods(GId) --商品外键

)

--订单表

create table OrderInfo

(

OId int primary key identity,

OrderNum varchar(max),

CreateTime datetime,

Count int,

UId int foreign key references UserInfo(UId), --用户外键

GId int foreign key references Goods(GId) --商品外键

)

--分页显示存储过程

create proc sp_Show

(

@index int,

@size int,

@totalcount int out, --总数据数

@pagecount int out --总页数

)

as

begin

--如果当前页数小于一

if(@index<1)

begin

set @index=1

end

--计算总数据数

select @totalcount=count(*) from Goods

--计算总页数

set @pagecount=CEILING(@totalcount*1.0/@size)

--分页查询

select * from

(select *,ROW_NUMBER() over (order by GId) rn from Goods) tb1 where rn between (@index-1)*@size+1 and @index*@size

end

declare @x int,@y int

exec sp_Show 1,2,@x out,@y out

select @x,@y

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值