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


C# DbType.GetType方法代码示例

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


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

示例1: DBType2NUnitTestValue

			// <summary>
			// Aimed for NUnit testing.
			// </summary>
			public static string DBType2NUnitTestValue(DbType dbType_in) {
				switch (dbType_in) {
					case DbType.DateTime:
					case DbType.Date:
					case DbType.Time: {
						// sql server friendly
						return "new DateTime(2341, 12, 12)";
					}
					case DbType.Int64:
					case DbType.UInt64: {
						return "123L";
					}
					case DbType.Int16: 
					case DbType.Int32: 
					case DbType.UInt16: 
					case DbType.UInt32: 
					case DbType.Byte: 
					case DbType.Single: 
					case DbType.Double: 
					case DbType.Decimal: {
						return "123";
					}
					case DbType.Boolean: {
						return "true";
					}
					case DbType.String: {
						return "\"123\"";
					}
					case DbType.Guid: {
						return "Guid.NewGuid()";
					}
					case DbType.Binary: {
						return "new Byte[] { 1, 2, 3 }";
					}

// ToDos: here! check if appropriate...
//case DbType.Single:
//return "0F";

					// ToDos: here!
				}

				throw new Exception(string.Format(
					"undefined variable type: {0}",
					dbType_in.GetType().ToString()
				));
			}
开发者ID:katshann,项目名称:ogen,代码行数:50,代码来源:utils.cs

示例2: DBType2NUnitTestValue

		// <summary>
		// Aimed for NUnit testing.
		// </summary>
		public static string DBType2NUnitTestValue(DbType dbType_in) {
			switch (dbType_in) {
				case DbType.DateTime:
				case DbType.Date:
				case DbType.Time:
					// sql server friendly
					return "new DateTime(2341, 12, 12)";

				case DbType.Int64:
				case DbType.UInt64:
					return "123L";

				case DbType.Int16: 
				case DbType.Int32: 
				case DbType.UInt16: 
				case DbType.UInt32: 
				case DbType.Byte: 
				case DbType.Single: 
				case DbType.Double: 
				case DbType.Decimal:
					return "123";

				case DbType.Boolean:
					return "true";

				case DbType.String:
				case DbType.StringFixedLength:
				case DbType.AnsiString:
				case DbType.AnsiStringFixedLength:
					return "\"123\"";

				case DbType.Guid:
					return "Guid.NewGuid()";

				case DbType.Binary:
					return "new Byte[] { 1, 2, 3 }";

// ToDos: here! check if appropriate...
//case DbType.Single:
//return "0F";

				// ToDos: here!
			}

			throw new Exception(string.Format(
				System.Globalization.CultureInfo.CurrentCulture,
				"undefined variable type: {0}",
				dbType_in.GetType().ToString()
			));
		}
开发者ID:katshann,项目名称:ogen,代码行数:53,代码来源:DBUtilities.cs

示例3: DbType2NSysType

			// ToDos: here! have a look at: sSqlDbType.cs
			#region public static string DbType2NSysType(...);
			// <summary>
			// Aimed for code generator, hence returning straight string.
			// NSysType - .Net System Type
			// </summary>
			public static string DbType2NSysType(DbType dbType_in) {
				switch (dbType_in) {
					case DbType.Boolean: {
						return "bool"; //typeof(bool).Name;
					}
					case DbType.Int16: {
						return typeof(Int16).Name;
					}
					case DbType.Int32: {
						return "int"; //typeof(int).Name;
					}
					case DbType.Int64: {
						return "long"; //typeof(long).Name;
					}
					case DbType.UInt16: {
						return typeof(UInt16).Name;
					}
					case DbType.UInt32: {
						return typeof(UInt32).Name;
					}
					case DbType.UInt64: {
						return typeof(UInt64).Name;
					}
					case DbType.String: {
							return "string"; //typeof(string).Name;
					}
					case DbType.DateTime:
					case DbType.Date:
					case DbType.Time: {
						return typeof(DateTime).Name;
					}
					case DbType.Guid: {
						return typeof(Guid).Name;
					}
					case DbType.Byte: {
						return typeof(Byte).Name;
					}
					case DbType.Object: {
						return typeof(Object).Name;
					}

					case DbType.Single: {
						// ToDos: here! check if appropriate...
						return typeof(Single).Name;
					}
					case DbType.Binary: {
						// ToDos: here! check if appropriate...
						return typeof(Byte[]).Name;
					}
					case DbType.Decimal: {
						// ToDos: here! check if appropriate...
						return typeof(Decimal).Name;
					}
					case DbType.Double: {
						// ToDos: here! check if appropriate...
						return typeof(Double).Name;
					}

					case DbType.AnsiString:
					case DbType.AnsiStringFixedLength:
					case DbType.Currency:
					case DbType.SByte:
					case DbType.StringFixedLength:
					case DbType.VarNumeric: {
						// ToDos: here!
						break;
					}

					default: {
						break;
					}
				}

				throw new Exception(string.Format(
					"undefined variable type: {0}",
					dbType_in.GetType().ToString()
				));
			}
开发者ID:katshann,项目名称:ogen,代码行数:84,代码来源:utils.cs

示例4: DbType2NSysType

		// ToDos: here! have a look at: sSqlDbType.cs
		#region public static string DbType2NSysType(...) {
		// <summary>
		// Aimed for code generator, hence returning straight string.
		// NSysType - .Net System Type
		// </summary>
		/// <param name="dbType_in"></param>
		/// <returns></returns>
		public static string DbType2NSysType(DbType dbType_in) {
			switch (dbType_in) {
				case DbType.Boolean:
					return "bool"; //typeof(bool).Name;

				case DbType.Int16:
					return typeof(short).Name;

				case DbType.Int32:
					return "int"; //typeof(int).Name;

				case DbType.Int64:
					return "long"; //typeof(long).Name;

				case DbType.UInt16:
					return typeof(ushort).Name;

				case DbType.UInt32:
					return typeof(uint).Name;

				case DbType.UInt64:
					return typeof(ulong).Name;

				case DbType.String:
				case DbType.StringFixedLength:
				case DbType.AnsiString:
				case DbType.AnsiStringFixedLength:
					return "string"; //typeof(string).Name;

				case DbType.DateTime:
				case DbType.Date:
				case DbType.Time:
					return typeof(DateTime).Name;

				case DbType.Guid:
					return typeof(Guid).Name;

				case DbType.Byte:
					return typeof(byte).Name;

				case DbType.Object:
					return typeof(object).Name;

				case DbType.Single:
					// ToDos: here! check if appropriate...
					return typeof(float).Name;

				case DbType.Binary:
					// ToDos: here! check if appropriate...
					return typeof(byte[]).Name;

				case DbType.Decimal:
					// ToDos: here! check if appropriate...
					return typeof(decimal).Name;

				case DbType.Double:
					// ToDos: here! check if appropriate...
					return typeof(double).Name;

				case DbType.Currency:
				case DbType.SByte:
				case DbType.VarNumeric:
					// ToDos: here!
					break;

				default: {
					break;
				}
			}

			throw new Exception(string.Format(
				System.Globalization.CultureInfo.CurrentCulture,
				"undefined variable type: {0}",
				dbType_in.GetType().ToString()
			));
		}
开发者ID:katshann,项目名称:ogen,代码行数:84,代码来源:DBUtilities.cs


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