9.用ExecuteSqlCommand执行存储过程
时间:2021-07-01 10:21:17
帮助过:42人阅读
NOT EXISTS (
SELECT * FROM sys.objects
WHERE object_id =
OBJECT_ID(N
‘[dbo].[CreateAuthor]‘)
AND type
in (N
‘P‘, N
‘PC‘))
BEGIN
EXEC dbo.sp_executesql
@statement = N
‘
CREATE PROCEDURE [dbo].[CreateAuthor]
@FirstName Varchar(50),
@LastName Varchar(50),
@Address Varchar(100)
AS
INSERT INTO dbo.Authors(
[FirstName],
[LastName],
[Address]
)
VALUES (@FirstName, @LastName, @Address)
‘
using (var context = new BookStore())
{
int affectedRows = context.Database.ExecuteSqlCommand("CreateAuthor @p0, @p1, @p2",
parameters: new[]
{
"Mark",
"Cuban",
"23 Tsawassen Blvd."
});
}
9.用ExecuteSqlCommand执行存储过程
标签:cts exist 执行存储过程 te pro sys data span object_id fir