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


C# DbManager.SetCommand方法代码示例

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


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

示例1: GetPersonDictionary2

		// The dictionary key is built from a recordset field value ('@' prefix).
		//
		Dictionary<int, Person> GetPersonDictionary2()
		{
			using (DbManager db = new DbManager())
			{
				return db
					.SetCommand("SELECT * FROM Person")
					./*[a]*/ExecuteDictionary/*[/a]*/<int, Person>(/*[a]*/"@PersonID"/*[/a]*/);
			}
		}
开发者ID:MajidSafari,项目名称:bltoolkit,代码行数:11,代码来源:ExecuteDictionary.cs

示例2: SetCommandWorksCorrectlyWithSprocParameterPrefixSet

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

			try
			{
				using (var db = new DbManager(ProviderName.MySql))
				{
					var person = db.SetCommand(
							"SELECT * FROM Person WHERE PersonID = ?PersonID",
							db.Parameter("?PersonID", 1))
						.ExecuteObject<Person>();

					Assert.IsNotNull(person);
					Assert.AreEqual(1, person.ID);

					var person2 = db.SetCommand(
							"SELECT * FROM Person WHERE FirstName = ?firstName AND LastName = ?lastName",
							db.CreateParameters(person))
						.ExecuteObject<Person>();

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

示例3: 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

示例4: GetPersonByID

		// Insert, Update, and Delete a person.
		//
		public Person GetPersonByID(DbManager db, int id)
		{
			return db
				./*[a]*/SetCommand/*[/a]*/("SELECT * FROM Person WHERE PersonID = @id",
					db./*[a]*/Parameter/*[/a]*/("@id", id))
				.ExecuteObject<Person>();
		}
开发者ID:MajidSafari,项目名称:bltoolkit,代码行数:9,代码来源:SetCommand.cs

示例5: Test

		public void Test()
		{
			using (DbManager db = new DbManager())
			{
				List<Person> list = db
					.SetCommand(@"
						SELECT
							ps.*,
							d.Taxonomy,
							p.Diagnosis,
							CASE
								WHEN d.PersonID IS NOT NULL THEN 'D'
								WHEN p.PersonID IS NOT NULL THEN 'P'
							END as PersonType
						FROM
							Person ps
								LEFT JOIN Doctor  d ON d.PersonID = ps.PersonID
								LEFT JOIN Patient p ON p.PersonID = ps.PersonID
						ORDER BY
							ps.PersonID")
					.ExecuteList<Person>();

				Assert.AreEqual(list[0].GetType(), /*[a]*/typeof(Doctor)/*[/a]*/);
				Assert.AreEqual(list[1].GetType(), /*[a]*/typeof(Patient)/*[/a]*/);

				if (list.Count > 2)
					Assert.AreEqual(list[2].GetType(), typeof(Person));
			}
		}
开发者ID:MajidSafari,项目名称:bltoolkit,代码行数:29,代码来源:ObjectFactory.cs

示例6: Test1

		public void Test1()
		{
			List<Parent> parents = new List<Parent>();
			MapResultSet[] sets = new MapResultSet[2];

			sets[0] = new MapResultSet(typeof(Parent), parents);
			sets[1] = new MapResultSet(typeof(Child));

			sets[0].AddRelation(sets[1], "ParentID", "ParentID", "Children");
			sets[1].AddRelation(sets[0], "ParentID", "ParentID", "Parent");

			using (DbManager db = new DbManager())
			{
				db
					.SetCommand(_parentChildquery)
					.ExecuteResultSet(sets);
			}

			foreach (Parent p in parents)
			{
				Assert.That(p.IsDirty == false);

				foreach (Child c in p.Children)
					Assert.That(c.IsDirty == false);
			}
		}
开发者ID:MajidSafari,项目名称:bltoolkit,代码行数:26,代码来源:ComplexMappingTest.cs

示例7: DeleteByMemoID

 public void DeleteByMemoID(int MemoID)
 {
     using (DbManager dbm = new DbManager())
     {
         dbm.SetCommand(string.Format("DELETE FROM GENMEMODTL WHERE GENMEMOID = {0}", MemoID)).ExecuteNonQuery();
     }
 }
开发者ID:DennisPitallano,项目名称:IRMS-MARKETING,代码行数:7,代码来源:GeneralMemoConcessionDetailManager.cs

示例8: Test

		public void Test()
		{
			using (DbManager db = new DbManager())
			{
				List<SimpleObject> list = new List<SimpleObject>();

				db
#if MSSQL || SQLCE
					.SetCommand(@"
						SELECT 0 as [Key], 'value0' as Value UNION
						SELECT 1 as [Key], 'value1' as Value UNION
						SELECT 2 as [Key], 'value2' as Value")

#else // ORACLE || FIREBIRD || ACCESS

					.SetCommand(@"
						SELECT 0 as ""Key"", 'value0' as ""Value"" FROM Dual UNION
						SELECT 1 as ""Key"", 'value1' as ""Value"" FROM Dual UNION
						SELECT 2 as ""Key"", 'value2' as ""Value"" FROM Dual")
#endif
					.ExecuteList<SimpleObject>(list);

				Assert.IsTrue(list.Count > 0);
			}
		}
开发者ID:MajidSafari,项目名称:bltoolkit,代码行数:25,代码来源:ExecuteListT.cs

示例9: TearDown

 protected override void TearDown()
 {
     using (var dbManager = new DbManager("PerformanceTest"))
         dbManager
             .SetCommand("TRUNCATE TABLE Simplests")
             .ExecuteNonQuery();
 }
开发者ID:sdanyliv,项目名称:ormbattle,代码行数:7,代码来源:BLToolkitTest.cs

示例10: Test

		public void Test()
		{
			const string path = @"..\..\..\..\Data\Create Scripts\SqlCe.sql";

			using (DbManager db = new DbManager())
			{
				string cmd  = string.Empty;
				string term = "GO";

				foreach (string s in File.ReadAllLines(path))
				{
					string line = s.TrimEnd();

					if (!line.EndsWith(term))
					{
						cmd += line + Environment.NewLine;
						continue;
					}

					line = line.Substring(0, line.Length - term.Length).Trim();

					Console.WriteLine("Executing script:");
					Console.WriteLine(cmd + line);

					db
						.SetCommand(cmd + line)
						.ExecuteNonQuery()
						;

					Console.WriteLine("Succeeded.");

					cmd = string.Empty;
				}
			}
		}
开发者ID:MajidSafari,项目名称:bltoolkit,代码行数:35,代码来源:CreateDatabase.cs

示例11: DeleteByMemoNo

 public void DeleteByMemoNo(string MemoNo)
 {
     using (DbManager dbm = new DbManager())
     {
         dbm.SetCommand(string.Format("DELETE FROM PRICEPOINT WHERE MEMONO = '{0}'", MemoNo)).ExecuteNonQuery();
     }
 }
开发者ID:DennisPitallano,项目名称:IRMS-MARKETING,代码行数:7,代码来源:PricePointManager.cs

示例12: GetPersonList

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

示例13: GetPersonListSqlText

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

示例14: GetNameList2

		List<string> GetNameList2()
		{
			using (DbManager db = new DbManager())
			{
				return db
					.SetCommand("SELECT * FROM Person")
					./*[a]*/ExecuteScalarList/*[/a]*/<string>(/*[a]*/"FirstName"/*[/a]*/);
			}
		}
开发者ID:MajidSafari,项目名称:bltoolkit,代码行数:9,代码来源:ExecuteScalarList.cs

示例15: button4_Click

 private void button4_Click(object sender, EventArgs e)
 {
     string sql = textBox1.Text.TrimEnd();
     if (sql.Length == 0) return;
     ;
     DbManager mgr = new DbManager();
     mgr.SetCommand(sql).ExecuteNonQuery();
     MessageBox.Show("表创建完成");
 }
开发者ID:BeanHsiang,项目名称:DbTableBuilder,代码行数:9,代码来源:Form1.cs


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