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


C# DbManager.SetSpCommand方法代码示例

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


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

示例1: SprocParameterPrefixShouldBeSpecifiedManuallyWhenItIsNotSet

		public void SprocParameterPrefixShouldBeSpecifiedManuallyWhenItIsNotSet()
		{
			using (var db = new DbManager(ProviderName.MySql))
			{
				var person = db.SetSpCommand("GetPersonById", db.Parameter("?_ID", 1)).ExecuteObject<Person>();
				Assert.IsNotNull(person);

				var person2 = db.SetSpCommand(
						"GetPersonByName", 
						db.Parameter("?_lastName", person.LastName),
						db.Parameter("?_firstName", person.FirstName))
					.ExecuteObject<Person>();
				Assert.IsNotNull(person2);
			}
		}
开发者ID:Gremlin2,项目名称:bltoolkit,代码行数:15,代码来源:MySqlSprocParameterPrefixTests.cs

示例2: GetPersonListSproc

		IList<Person> GetPersonListSproc()
		{
			using (DbManager db = new DbManager())
			{
				return db
					.SetSpCommand("Person_SelectAll")
					./*[a]*/ExecuteList<Person>()/*[/a]*/;
			}
		}
开发者ID:MajidSafari,项目名称:bltoolkit,代码行数:9,代码来源:ExecuteList.cs

示例3: GetCustomPersonList

		void GetCustomPersonList(IList list)
		{
			using (DbManager db = new DbManager())
			{
				db
					.SetSpCommand("Person_SelectAll")
					./*[a]*/ExecuteList(list, typeof(Person))/*[/a]*/;
			}
		}
开发者ID:MajidSafari,项目名称:bltoolkit,代码行数:9,代码来源:ExecuteList.cs

示例4: GetByUserId

 public List<LogEntity> GetByUserId(int userId)
 {
     using (var db = new DbManager())
     {
         return db
             .SetSpCommand("GetLogsByUserId", userId)
             .ExecuteList<LogEntity>();
     }
 }
开发者ID:dizar888,项目名称:News,代码行数:9,代码来源:LogsAccessor.cs

示例5: GetById

 public LogEntity GetById(int id)
 {
     using (var db = new DbManager())
     {
         return db
             .SetSpCommand("GetLogById", id)
             .ExecuteObject<LogEntity>();
     }
 }
开发者ID:dizar888,项目名称:News,代码行数:9,代码来源:LogsAccessor.cs

示例6: GetAll

 public List<LogEntity> GetAll()
 {
     using (var db = new DbManager())
     {
         return db
             .SetSpCommand("GetAllLogs")
             .ExecuteList<LogEntity>();
     }
 }
开发者ID:dizar888,项目名称:News,代码行数:9,代码来源:LogsAccessor.cs

示例7: GetPersonList

		// Select a person list.
		//
		public IList<Person> GetPersonList()
		{
			using (DbManager db = new DbManager())
			{
				return db
					./*[a]*/SetSpCommand/*[/a]*/("Person_SelectAll")
					.ExecuteList<Person>();
			}
		}
开发者ID:MajidSafari,项目名称:bltoolkit,代码行数:11,代码来源:SetSpCommand.cs

示例8: GetPersonSproc2

		Person GetPersonSproc2(int id)
		{
			using (DbManager db = new DbManager())
			{
				return db
					.SetSpCommand("Person_SelectByKey", id)
					./*[a]*/ExecuteObject<Person>()/*[/a]*/;
			}
		}
开发者ID:MajidSafari,项目名称:bltoolkit,代码行数:9,代码来源:ExecuteObject.cs

示例9: ReturnValueTest2

		public void ReturnValueTest2()
		{
			using (DbManager db = new DbManager())
			{
				int n = db
					.SetSpCommand("Scalar_ReturnParameter")
					.ExecuteScalar<int>(ScalarSourceType.ReturnValue);

				Assert.AreEqual(12345, n);
			}
		}
开发者ID:MajidSafari,项目名称:bltoolkit,代码行数:11,代码来源:Parameter.cs

示例10: GetPersonByID2

		public Person GetPersonByID2(int id)
		{
			using (DbManager db = new DbManager())
			{
				// Pass a parameter using the [b]params[/b] parameter of the SetSpCommand method.
				//
				return db
					./*[a]*/SetSpCommand/*[/a]*/("Person_SelectByKey", /*[a]*/id/*[/a]*/)
					.ExecuteObject<Person>();
			}
		}
开发者ID:MajidSafari,项目名称:bltoolkit,代码行数:11,代码来源:SetSpCommand.cs

示例11: GetPersonByID1

		// Select a person.
		//
		public Person GetPersonByID1(int id)
		{
			using (DbManager db = new DbManager())
			{
				// Pass a parameter using the [b]Parameter[/b] method.
				//
				return db
					./*[a]*/SetSpCommand/*[/a]*/("Person_SelectByKey",
						db./*[a]*/Parameter/*[/a]*/("@id", id))
					.ExecuteObject<Person>();
			}
		}
开发者ID:MajidSafari,项目名称:bltoolkit,代码行数:14,代码来源:SetSpCommand.cs

示例12: ParameterPrefixTest

		public void ParameterPrefixTest()
		{
			var oldPrefix = MySqlDataProvider.SprocParameterPrefix;
			MySqlDataProvider.SprocParameterPrefix = "_";

			try
			{
				using (var db = new DbManager(ProviderName.MySql))
				{
					var person = db.SetSpCommand("GetPersonById", db.Parameter("?ID", 1)).ExecuteObject<Person>();
					Assert.IsNotNull(person);

					var person2 = db.SetSpCommand("GetPersonByName", db.CreateParameters(person)).ExecuteObject<Person>();
					Assert.IsNotNull(person2);

					Assert.AreEqual(person, person2);
				}
			}
			finally
			{
				MySqlDataProvider.SprocParameterPrefix = oldPrefix;
			}
		}
开发者ID:pbludov,项目名称:bltoolkit,代码行数:23,代码来源:MySqlSprocParameterPrefixTests.cs

示例13: Test

		public void Test()
		{
			List<Person> list = new List<Person>
			{
				new Person { FirstName = "John", LastName = "Smith", Gender = Gender.Male   },
				new Person { FirstName = "Jane", LastName = "Smith", Gender = Gender.Female }
			};

			using (DbManager db = new DbManager())
			{
				db.BeginTransaction();

				// Prepare command.
				//
				db
					.SetSpCommand("Person_Insert",
						db.CreateParameters(list[0]))
					./*[a]*/Prepare/*[/a]*/();

				// Insert.
				//
				foreach (Person person in list)
				{
					db./*[a]*/AssignParameterValues/*[/a]*/(person);
					db.ExecuteNonQuery();
				}

				// Check the result.
				//
				list = db
					.SetCommand(
						"SELECT * FROM Person WHERE LastName = @lastName",
						db.Parameter("@lastName", "Smith"))
					.ExecuteList<Person>();

				Assert.GreaterOrEqual(2, list.Count);

				// Cleanup.
				//
				db
					.SetCommand(
						"DELETE FROM Person WHERE LastName = @lastName",
						db.Parameter("@lastName", "Smith"))
					.ExecuteNonQuery();

				db.CommitTransaction();
			}
		}
开发者ID:MajidSafari,项目名称:bltoolkit,代码行数:48,代码来源:Prepare.cs

示例14: Main

        static void Main(string[] args)
        {
            using (var db = new DbManager())
            {
                db.SetSpCommand(""); // ok
                db.SetInsertCommand(""); // ok
                db.SetUpdateCommand(""); // ok
                db.Prepare(); // ok
                db.ExecuteNonQuery(); // ok

                db.SetCommand(""); // ERROR:
                    // error CS0584: Internal compiler error: Object reference not set to an instance of an object
                    // error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement

            }
        }
开发者ID:neris,项目名称:BLToolkit-Mono-compiler-bug,代码行数:16,代码来源:Program.cs

示例15: ReturnValueTest

		public void ReturnValueTest()
		{
			using (DbManager db = new DbManager())
			{
				/*
				 * CREATE Function Scalar_ReturnParameter()
				 * RETURNS int
				 * AS
				 * BEGIN
				 *     RETURN 12345
				 * END
				 */
				int n = db
					.SetSpCommand("Scalar_ReturnParameter")
					./*[a]*/ExecuteScalar/*[/a]*/<int>(/*[a]*/ScalarSourceType.ReturnValue/*[/a]*/);

				Assert.AreEqual(12345, n);
			}
		}
开发者ID:MajidSafari,项目名称:bltoolkit,代码行数:19,代码来源:ExecuteScalar.cs


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