当前位置: 首页>>代码示例>>C#>>正文


C# StoredProcedure.Execute方法代码示例

本文整理汇总了C#中StoredProcedure.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# StoredProcedure.Execute方法的具体用法?C# StoredProcedure.Execute怎么用?C# StoredProcedure.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StoredProcedure的用法示例。


在下文中一共展示了StoredProcedure.Execute方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SP_Should_Execute_Without_Parameter2

 public void SP_Should_Execute_Without_Parameter2()
 {
     StoredProcedure sp = new StoredProcedure("Ten Most Expensive Products", DataService.Providers["Northwind"]);
     int count = 0;
     using (IDataReader rdr =sp.GetReader())
     {
         while (rdr.Read())
             count++;
         rdr.Close();
     }
     sp.Execute();
     Assert.IsTrue(count > 0);
 }
开发者ID:khurram063,项目名称:SubSonic-2.0,代码行数:13,代码来源:SPs.cs

示例2: TestTransaction

        public void TestTransaction()
        {
            using (DbConnection connection = GetConnection())
            {
                connection.Open();

                DbTransaction transaction = connection.BeginTransaction();

                const string newName = "changed";

                StoredProcedure changeName = new StoredProcedure("ChangeName");
                changeName.Command.AddParameter("@Id", 2, DbType.Int32, 4);
                changeName.Command.AddParameter("@NewName", newName, DbType.String, 50);
                changeName.Execute(transaction);

                StoredProcedure getName = new StoredProcedure("GetName");
                getName.Command.AddParameter("@Id", 2, DbType.Int32, 4);
                Assert.AreEqual(newName, getName.ExecuteScalar(transaction), "The name has not been changed");

                transaction.Rollback();

                Assert.AreEqual("name2", getName.ExecuteScalar(), "The name has not been reverted");

                connection.Close();
            }
        }
开发者ID:jeremysimmons,项目名称:sixpack-library,代码行数:26,代码来源:StoredProcedureTests.cs

示例3: SP_Outputs_DefaultProvider

        public void SP_Outputs_DefaultProvider()
        {
            StoredProcedure sp = new StoredProcedure("SubSonicTestNW", DataService.GetInstance("Northwind"));
            sp.Command.AddOutputParameter("@param");
            sp.Execute();

            //make sure there's outputs
            Assert.IsTrue(sp.OutputValues.Count > 0);

            //this SP just returns today's date.
            //make sure it's right now!
            DateTime dTest = Convert.ToDateTime(sp.OutputValues[0]);
            Assert.IsTrue(dTest.Date == DateTime.Now.Date);
        }
开发者ID:khurram063,项目名称:SubSonic-2.0,代码行数:14,代码来源:SPs.cs

示例4: TestOutputParameterGeneric

        public void TestOutputParameterGeneric()
        {
            StoredProcedure sp = new StoredProcedure("OutputParameter", "default");
            sp.Command.AddParameter("@First", 2, DbType.Int32, 4);
            sp.Command.AddParameter("@Second", 3, DbType.Int32, 4);
            sp.Command.AddOutParameter("@Result", DbType.Int32, 4);

            int result;
            sp.Execute(out result);

            Assert.AreEqual(5, result);
        }
开发者ID:jeremysimmons,项目名称:sixpack-library,代码行数:12,代码来源:StoredProcedureTests.cs


注:本文中的StoredProcedure.Execute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。