📜  实体框架调用带有参数的存储过程 - 任何代码示例

📅  最后修改于: 2022-03-11 15:00:27.049000             🧑  作者: Mango

代码示例2
using (var entities = new YourEntities())
                {
                    SqlParameter[] parameters =
                      {
                          new SqlParameter{
                                SqlDbType = SqlDbType.NVarChar,
                                Size = -1,
                                Direction = ParameterDirection.Input,
                                ParameterName = "InCompanyCode",
                                Value = SD.Company
                            },
                            new SqlParameter{
                                SqlDbType = SqlDbType.NVarChar,
                                Size = -1,
                                Direction = ParameterDirection.Input,
                                ParameterName = "InDebugModeOn",
                                Value = "0"
                            }
                        };

                   return entities.Database.SqlQuery
                        (@"EXECUTE YourSP @InCompanyCode,@InBranchCode", parameters).ToList();                }