Getting a result feedback from a stored procedure in Entity Framework

后端 未结 4 1353
野性不改
野性不改 2021-01-21 09:02

In a SQL Server 2008 I have a simple stored procedure moving a bunch of records to another table:

CREATE PROCEDURE [dbo].MyProc(@ParamRecDateTime [datetime])
AS
         


        
4条回答
  •  走了就别回头了
    2021-01-21 09:53

    using (dbContext db = new dbContext())
    {
    var parameters = new[]
    {
    new SqlParameter("@1","Input Para value"),
    new SqlParameter("@2",SqlDbType.VarChar,4){ Value = "default if you want"},
    new SqlParameter("@3",SqlDbType.Int){Value = 0},
    new SqlParameter("@4","Input Para Value"),
    new SqlParameter("@5",SqlDbType.VarChar,10 ) {   Direction = ParameterDirection.Output   },
    new SqlParameter("@6",SqlDbType.VarChar,1000) {   Direction = ParameterDirection.Output   }
    };
    db.ExecuteStoreCommand("EXEC SP_Name @1,@2,@3,@4,@5 OUT,@6 OUT", parameters);
    ArrayList ObjList = new ArrayList();
    ObjList.Add(parameters[1].Value);
    ObjList.Add(parameters[2].Value);
    }
    

提交回复
热议问题