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


C# DbManager.GetConvertTypeToParameter方法代码示例

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


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

示例1: CreateParametersSqlTest

		public void CreateParametersSqlTest()
		{
			using (DbManager db = new DbManager())
			{
				DataTypeSqlTest dt = new DataTypeSqlTest();
				
				dt.ID        = 12345;
				dt.Binary_   = new SqlBinary(new byte[2] {1, 2});
				dt.Boolean_  = new SqlBoolean(1);
				dt.Byte_     = new SqlByte(250);
				dt.DateTime_ = new SqlDateTime(DateTime.Now);
				dt.Decimal_  = new SqlDecimal(9876543210.0m);
				dt.Double_   = new SqlDouble(12345.67890);
				dt.Guid_     = new SqlGuid(Guid.Empty);
				dt.Int16_    = new SqlInt16(12345);
				dt.Int32_    = new SqlInt32(1234567890);
				dt.Int64_    = new SqlInt64(1234567890123456789);
				dt.Money_    = new SqlMoney(99876543210.0m);
				dt.Single_   = new SqlSingle(1234.0f);
				dt.String_   = new SqlString("Crazy Frog");

#if !SQLCE
				dt.Bytes_    = new SqlBytes(new byte[2] {2, 1});
				dt.Chars_    = new SqlChars(new char[2] {'B', 'L'});
				dt.Xml_      = new SqlXml(new XmlTextReader(new StringReader("<xml/>")));
#endif

				var parameters = db.CreateParameters(dt);

				Assert.IsNotNull(parameters);
				Assert.AreEqual(ObjectMapper<DataTypeSqlTest>.Instance.Count, parameters.Length);

				foreach (MemberMapper mm in ObjectMapper<DataTypeSqlTest>.Instance)
				{
					var pName = (string)db.DataProvider.Convert(mm.Name, db.GetConvertTypeToParameter());
					var p     = Array.Find(parameters, obj => obj.ParameterName == pName);

					Assert.IsNotNull(p);
					Assert.AreEqual(mm.GetValue(dt), p.Value);
				}
			}
		}
开发者ID:devmlog,项目名称:bltoolkit,代码行数:42,代码来源:DbManagerTest.cs

示例2: NonUpdatableTest

		public void NonUpdatableTest()
		{
			var da = new SqlQuery();

			using (var db = new DbManager())
			{
				var update = da.GetSqlQueryInfo<TestCategory>(db, "Update");
				var insert = da.GetSqlQueryInfo<TestCategory>(db, "Insert");

				Assert.That(update.QueryText, Is.Not.Contains(
					"\t" + db.DataProvider.Convert("Id", ConvertType.NameToQueryField) + " = " + db.DataProvider.Convert("Id", db.GetConvertTypeToParameter()) + "\n"),
					"Update");
				Assert.That(insert.QueryText, Is.Not.Contains("Id"), "Insert");
			}
		}
开发者ID:x64,项目名称:bltoolkit,代码行数:15,代码来源:SqlTest.cs

示例3: CreateParametersTest

		public void CreateParametersTest()
		{
			using (var db = new DbManager())
			{
				var dt = new DataTypeTest
				{
					ID        = 12345,
					Binary_   = new byte[2] {1, 2},
#if !ORACLE
					Boolean_  = true,
					Guid_     = Guid.Empty,
#endif
					Byte_     = 250,
					Bytes_    = new byte[] { 2, 1 },
					DateTime_ = DateTime.Now,
					Decimal_  = 9876543210.0m,
					Double_   = 12345.67890,
					Int16_    = 12345,
					Int32_    = 1234567890,
					Int64_    = 1234567890123456789,
					Money_    = 99876543210.0m,
					Single_   = 1234.0f,
					String_   = "Crazy Frog",

					Char_     = 'F',
					SByte_    = 123,
					//UInt16_   = 65432,
					//UInt32_   = 4000000000,
					//UInt64_   = 12345678901234567890,
#if !SQLCE
					Stream_   = new MemoryStream(5),
					Xml_      = new XmlTextReader(new StringReader("<xml/>")),
#endif
				};

				var parameters = db.CreateParameters(dt);

				Assert.IsNotNull(parameters);
				Assert.AreEqual(ObjectMapper<DataTypeTest>.Instance.Count, parameters.Length);

				foreach (MemberMapper mm in ObjectMapper<DataTypeTest>.Instance)
				{
					var paramName = (string)db.DataProvider.Convert(mm.Name, db.GetConvertTypeToParameter());
					var p         = parameters.First(obj => obj.ParameterName == paramName);

					Assert.IsNotNull(p);
					Assert.AreEqual(mm.GetValue(dt), p.Value, mm.MemberName);
				}
			}
		}
开发者ID:devmlog,项目名称:bltoolkit,代码行数:50,代码来源:DbManagerTest.cs

示例4: CreateParametersTest

		public void CreateParametersTest()
		{
			using (DbManager db = new DbManager())
			{
				DataTypeTest dt = new DataTypeTest();
				
				dt.ID        = 12345;
				dt.Binary_   = new byte[2] {1, 2};
#if !ORACLE
				dt.Boolean_  = true;
				dt.Guid_     = Guid.Empty;
#endif
				dt.Byte_     = 250;
				dt.Bytes_    = new byte[2] {2, 1};
				dt.DateTime_ = DateTime.Now;
				dt.Decimal_  = 9876543210.0m;
				dt.Double_   = 12345.67890;
				dt.Int16_    = 12345;
				dt.Int32_    = 1234567890;
				dt.Int64_    = 1234567890123456789;
				dt.Money_    = 99876543210.0m;
				dt.Single_   = 1234.0f;
				dt.String_   = "Crazy Frog";

				dt.Char_     = 'F';
				dt.SByte_    = 123;
				dt.UInt16_   = 65432;
				dt.UInt32_   = 4000000000;
				dt.UInt64_   = 12345678901234567890;
#if !SQLCE
				dt.Stream_   = new MemoryStream(5);
				dt.Xml_      = new XmlTextReader(new StringReader("<xml/>"));
				dt.XmlDoc_   = new XmlDocument(); dt.XmlDoc_.LoadXml("<xmldoc/>");
#endif

				IDbDataParameter[] parameters = db.CreateParameters(dt);

				Assert.IsNotNull(parameters);
				Assert.AreEqual(ObjectMapper<DataTypeTest>.Instance.Count, parameters.Length);

				foreach (MemberMapper mm in ObjectMapper<DataTypeTest>.Instance)
				{
					string paramName = (string)db.DataProvider.Convert(mm.Name, db.GetConvertTypeToParameter());
					IDbDataParameter p = Array.Find(parameters,
						delegate(IDbDataParameter obj) { return obj.ParameterName == paramName; });

					Assert.IsNotNull(p);
					Assert.AreEqual(mm.GetValue(dt), p.Value);
				}
			}
		}
开发者ID:pbludov,项目名称:bltoolkit,代码行数:51,代码来源:DbManagerTest.cs


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