Dapper作为轻量级ORM框架。因其优秀的性能。 整理一下Demo,方便自己和朋友查找
除了CURD之外, IN查询 联合查询 存储过程 分页查询
Demo:链接 提取码:jwb6
数据库:两个表 两个储存过程
Student表:
Book表:
数据库SQL:
SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[Book]( [BID] [int] IDENTITY(1,1) NOT NULL, [BookName] [varchar](50) NULL, [SID] [int] NULL, CONSTRAINT [PK_Book] PRIMARY KEY CLUSTERED ( [BID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO SET ANSI_PADDING OFF GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[Student]( [Uid] [int] IDENTITY(1,1) NOT NULL, [Name] [varchar](50) NULL, [BrithDay] [datetime] NULL, [Sex] [int] NULL, [Age] [int] NULL, [demo] [int] NULL, CONSTRAINT [PK_Student] PRIMARY KEY CLUSTERED ( [Uid] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO SET ANSI_PADDING OFF GO
存储过程:
SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: <Author,,Name> -- Create date: <Create Date,,> -- Description: <Description,,> -- ============================================= CREATE PROCEDURE [dbo].[sp_Student] @id int AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- Insert statements for procedure here SELECT * from Student where Uid = @id END GO
SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: <Author,,Name> -- Create date: <Create Date,,> -- Description: <Description,,> -- ============================================= CREATE PROCEDURE [dbo].[sp_StudentUpdate] @id int, @name varchar(50) AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. --SET NOCOUNT ON; -- Insert statements for procedure here update Student set Name=@name where Uid = @id;select @@ROWCOUNT END GO