1.编写存储过程
USE [数据库]
GO
/****** Object: StoredProcedure [dbo].[SP_CreateModel] Script Date: 2020-10-30 9:27:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- EXEC SP_CreateModel 'Core_Menu'
-- =============================================
CREATE PROCEDURE [dbo].[SP_CreateModel]
-- Add the parameters for the stored procedure here
@TableName varchar(256)
AS
BEGIN
SET NOCOUNT ON;
DECLARE @Result VARCHAR(MAX) = 'public class ' + @TableName + '
{
/// <summary>
/// 构造函数
/// </summary>
public ' + @TableName + '()
{
}
/// <summary>
/// 获取主键
/// </summary>
/// <returns></returns>
public override List<string> GetPrimaryKey()
{
List<string> result = new Li