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


C# DbType类代码示例

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


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

示例1: GetVariableType

		private static string GetVariableType(DbType dbType)
		{
			switch (dbType) {
				case DbType.AnsiString:
				case DbType.AnsiStringFixedLength:
				case DbType.String:
				case DbType.StringFixedLength: return "string";

				case DbType.Binary:		return "byte[]";
				case DbType.Boolean:	return "bool";
				case DbType.Byte:		return "byte";

				case DbType.Currency:
				case DbType.Decimal:
				case DbType.VarNumeric:	return "decimal";

				case DbType.Date:
				case DbType.DateTime:	return "DateTime";

				case DbType.Double:		return "double";
				case DbType.Guid:		return "Guid";
				case DbType.Int16:		return "short";
				case DbType.Int32:		return "int";
				case DbType.Int64:		return "long";
				case DbType.Object:		return "object";
				case DbType.SByte:		return "sbyte";
				case DbType.Single:		return "float";
				case DbType.Time:		return "TimeSpan";
				case DbType.UInt16:		return "ushort";
				case DbType.UInt32:		return "uint";
				case DbType.UInt64:		return "ulong";

				default:				return "string";
			}
		}
开发者ID:stevesloka,项目名称:bvcms,代码行数:35,代码来源:CSharpCodeLanguage.cs

示例2: ContainsRule

 public static bool ContainsRule(Csla.Core.BusinessBase obj, DbType type, string propertyName)
 {
     switch (type)
     {
         case DbType.Int16:
         case DbType.Int32:
         case DbType.Int64:
             return obj.BrokenRulesCollection.Any(
                  brokenRule => brokenRule.RuleName == string.Format("rule://epiworx.core.validation.integerrequired/{0}", propertyName))
                     || obj.BrokenRulesCollection.Any(
                         brokenRule => brokenRule.RuleName == string.Format("rule://csla.rules.commonrules.dataannotation/{0}?a=Epiworx.Core.Validation.IntegerRequiredAttribute", propertyName));
         case DbType.Decimal:
             return obj.BrokenRulesCollection.Any(
                 brokenRule => brokenRule.RuleName == string.Format("rule://epiworx.core.validation.decimalrequired/{0}", propertyName));
         case DbType.Date:
             return obj.BrokenRulesCollection.Any(
               brokenRule => brokenRule.RuleName == string.Format("rule://epiworx.core.validation.daterequired/{0}", propertyName));
         case DbType.DateTime:
             return obj.BrokenRulesCollection.Any(
               brokenRule => brokenRule.RuleName == string.Format("rule://epiworx.core.validation.datetimerequired/{0}", propertyName));
         case DbType.String:
         case DbType.StringFixedLength:
             return obj.BrokenRulesCollection.Any(
              brokenRule => brokenRule.RuleName == string.Format("rule://epiworx.core.validation.stringrequired/{0}", propertyName));
         default:
             throw new NotSupportedException();
     }
 }
开发者ID:mattruma,项目名称:epiworx-csla,代码行数:28,代码来源:ValidationHelper.cs

示例3: CouchBase

 protected CouchBase(string username, string password, AuthenticationType aT, DbType dbType)
 {
     this.username = username;
     this.password = password;
     this.authType = aT;
     this.dbType = dbType;
 }
开发者ID:kwokhou,项目名称:LoveSeat,代码行数:7,代码来源:CouchBase.cs

示例4: VarArgsSQLFunction

 /// <summary>
 /// Constructs a VarArgsSQLFunction instance with a 'static' return type.  An example of a 'static'
 /// return type would be something like an <code>UPPER</code> function which is always returning
 /// a SQL VARCHAR and thus a string type.
 /// </summary>
 /// <param name="registeredType">the return type</param>
 /// <param name="begin">the beginning of the function templating</param>
 /// <param name="sep">the separator for each individual function argument</param>
 /// <param name="end">the end of the function templating</param>
 public VarArgsSQLFunction(DbType registeredType, String begin, String sep, String end)
 {
     this.registeredType = registeredType;
     this.begin = begin;
     this.sep = sep;
     this.end = end;
 }
开发者ID:wyerp,项目名称:EasyDb.NET,代码行数:16,代码来源:VarArgsSQLFunction.cs

示例5: TypeName

        protected override string TypeName(DbType type) {
            switch (type) {
                case DbType.Binary:
                    return "bit";

                case DbType.Boolean:
                    return "smallint unsigned";

                case DbType.Byte:
                    return "smallint unsigned";

                case DbType.DateTime:
                case DbType.DateTime2:
                    return "timestamp";

                case DbType.DateTimeOffset:
                    return "timestamptz";

                case DbType.Double:
                    return "double precision";

                default:
                    return base.TypeName(type);
            }
        }
开发者ID:Polylytics,项目名称:dashing,代码行数:25,代码来源:AnsiSqlDialect.cs

示例6: Parameters

 public Parameters(string Name, object Value,DbType dbType)
 {
     ParamName = Name;
     ParamValue = Value;
     ParamDbType = dbType;
     ParamDirection = ParameterDirection.Input;
 }
开发者ID:xlgwr,项目名称:RFID,代码行数:7,代码来源:SQLiteHelper.cs

示例7: DBMapping

 public DBMapping(string first, string second, DbType type, int size)
 {
     this._first = first;
     this._second = second;
     this._type = type;
     this._size = size;
 }
开发者ID:vinStar,项目名称:FrameworkDemo,代码行数:7,代码来源:DBMapping.cs

示例8: CreateParameter

 public static void CreateParameter(this IDbCommand command, string name, DbType dbType)
 {
   IDbDataParameter parameter = command.CreateParameter();
   parameter.ParameterName = name;
   parameter.DbType = dbType;
   command.Parameters.Add(parameter);
 }
开发者ID:machine,项目名称:machine.mta,代码行数:7,代码来源:DatabaseHelpers.cs

示例9: RelationalTypeMapping

        public RelationalTypeMapping([NotNull] string defaultTypeName, DbType? storeType = null)
        {
            Check.NotEmpty(defaultTypeName, nameof(defaultTypeName));

            DefaultTypeName = defaultTypeName;
            StoreType = storeType;
        }
开发者ID:491134648,项目名称:EntityFramework,代码行数:7,代码来源:RelationalTypeMapping.cs

示例10: AddParam

 /// <summary>
 /// Extension for adding single parameter
 /// </summary>
 public static void AddParam(this DbCommand cmd, object item, DbType? type = null)
 {
     var p = cmd.CreateParameter();
     p.ParameterName = string.Format("@{0}", cmd.Parameters.Count);
     if (item == null)
     {
         p.Value = DBNull.Value;
     }
     else
     {
         if (item.GetType() == typeof(Guid))
         {
             p.Value = item.ToString();
             p.DbType = DbType.String;
             p.Size = 4000;
         }
         else if (item.GetType() == typeof(ExpandoObject))
         {
             var d = (IDictionary<string, object>)item;
             p.Value = d.Values.FirstOrDefault();
         }
         else
         {
             p.Value = item;
             if (type.HasValue)
                 p.DbType = type.Value;
         }
         if (item.GetType() == typeof(string))
             p.Size = ((string)item).Length > 4000 ? -1 : 4000;
     }
     cmd.Parameters.Add(p);
 }
开发者ID:Anupam-,项目名称:Ilaro.Admin,代码行数:35,代码来源:Massive.cs

示例11: Column

 public Column(string name, DbType type)
 {
     ColumnName = name;
     IsAutoIncrement = false;
     Type = type;
     IsNullable = true;
 }
开发者ID:sharpmigrations,项目名称:sharpmigrations,代码行数:7,代码来源:Column.cs

示例12: GetParameter

        protected override IDataParameter GetParameter(string name, object paramValue, DbType datatype)
        {
            object value = paramValue;
            DbType localDatatype = datatype;
            if (datatype == DbType.Guid)
                localDatatype = DbType.String;
            else
                localDatatype = datatype;

            NpgsqlParameter param;
            if (datatype == DbType.Guid && value != DBNull.Value)
            {
                value = new Guid(paramValue.ToString());
                param = new NpgsqlParameter(name, localDatatype);
                param.Value = value;
            }
            else
            {
                param = new NpgsqlParameter(name, value);
                param.DbType = localDatatype;

            }

            return param;
        }
开发者ID:JamesTryand,项目名称:alchemi,代码行数:25,代码来源:PostgresqlManagerDatabaseStorage.cs

示例13: ExtendedProperty

 public ExtendedProperty(string name, object value, DbType dataType, PropertyStateEnum state)
 {
     this.name = name;
     this.value = value;
     this.dataType = dataType;
     this.propertyState = state;
 }
开发者ID:hhahh2011,项目名称:CH.Cms,代码行数:7,代码来源:ExtendedProperty.cs

示例14: AreEqual

 public static void AreEqual(string parameterName, object value, DbType dbType, SqlParameter actual)
 {
     Assert.IsNotNull(actual, "Parameter should not be null.");
     Assert.AreEqual(parameterName, actual.ParameterName, "ParameterName");
     Assert.AreEqual(value, actual.Value, "Value");
     Assert.AreEqual(dbType, actual.DbType, "DbType");
 }
开发者ID:Corniel,项目名称:Qowaiv,代码行数:7,代码来源:SqlParameterAssert.cs

示例15: TryDetermineSubQueryDataType

 internal static void TryDetermineSubQueryDataType(SelectStatement query, out Type dataType, out DbType dbType)
 {
     // Automatically determine data type if possible.
     if (query.SelectList.Count == 1)
     {
         SelectItem firstItem = query.SelectList[0];
         if (firstItem.ItemType == SqlItemType.Column)
         {
             IDbColumn field = (IDbColumn)firstItem.Item;
             dataType = field.DataType;
             dbType = field.DbType;
         }
         else if (firstItem.ItemType == SqlItemType.Function)
         {
             Function function = (Function)firstItem.Item;
             dataType = function.DataType;
             dbType = function.DbType;
         }
         else
         {
             dataType = typeof(object);
             dbType = DbType.Object;
         }
     }
     else
     {
         dataType = typeof(object);
         dbType = DbType.Object;
     }
 }
开发者ID:lordfist,项目名称:FistCore.Lib,代码行数:30,代码来源:SqlItemUtil.cs


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