• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# DbType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: CreateParameter

		public DbParameter CreateParameter(Type connectionType, string sourceColumn, ParameterDirection parameterDirection, DbType parameterDbType, int parameterSize, byte parameterPrecision, byte parameterScale, bool parameterNullable, string parameterName, object parameterValue)
		{
			DbParameter dbParameter;

			if ((object)connectionType == null)
				throw new ArgumentNullException(nameof(connectionType));

			using (DbConnection dbConnection = (DbConnection)Activator.CreateInstance(connectionType))
			{
				using (DbCommand dbCommand = dbConnection.CreateCommand())
					dbParameter = dbCommand.CreateParameter();

				dbParameter.ParameterName = parameterName;
				dbParameter.Size = parameterSize;
				dbParameter.Value = parameterValue;
				dbParameter.Direction = parameterDirection;
				dbParameter.DbType = parameterDbType;
				this.ReflectionFascade.SetLogicalPropertyValue(dbParameter, "IsNullable", parameterNullable, true, false);
				dbParameter.Precision = parameterPrecision;
				dbParameter.Scale = parameterScale;
				dbParameter.SourceColumn = sourceColumn;

				return dbParameter;
			}
		}
开发者ID:textmetal,项目名称:main,代码行数:25,代码来源:AdoNetBufferingFascade.cs


示例17: CreateAndCacheDbCommandParameters

 public void CreateAndCacheDbCommandParameters(string sqlCommandText,
                                               DbCommand command,
                                               string[] paramNames,
                                               DbType[] paramDbTypes,
                                               object[] paramValues) 
 {
     lock (lockObject)
     {
         if (this.ParameterCache.IsCache(sqlCommandText))
         {
             this.ParameterCache.AddParametersFromCache(sqlCommandText, command, paramDbTypes, paramValues);
         }
         else
         {
             if (this.ParameterCache.IsCache(sqlCommandText))
             {
                 this.ParameterCache.AddParametersFromCache(sqlCommandText, command, paramDbTypes, paramValues);
             }
             else
             {
                 this.ParameterCache.CreateAndCacheParameters(sqlCommandText, command, paramNames, paramDbTypes, paramValues);
             }
         }
     }
 }
开发者ID:tu226,项目名称:Eagle,代码行数:25,代码来源:Database.cs


示例18: Add

 public void Add(string name, DbType type)
 {
     DbParameter parameter = Command.CreateParameter();
     parameter.ParameterName = string.Format("{0}{1}", ParameterPrefix, name);
     parameter.DbType = type;
     Command.Parameters.Add(parameter);
 }
开发者ID:Rejna,项目名称:RiotControl,代码行数:7,代码来源:DatabaseCommand.cs


示例19: EntityParameter

 public EntityParameter(string parameterName, DbType dbType, int size, string sourceColumn)
 {
     SetParameterNameWithValidation(parameterName, "parameterName");
     DbType = dbType;
     Size = size;
     SourceColumn = sourceColumn;
 }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:7,代码来源:EntityParameter.cs


示例20: DbParameterHelper

 public DbParameterHelper(DbType type, string name, object value, ParameterDirection direction)
 {
     DbType = type;
     Name = name;
     Value = value;
     Direction = direction;
 }
开发者ID:apdmatos,项目名称:geostatistics,代码行数:7,代码来源:DbParameterHelper.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# DbVariableReferenceExpression类代码示例发布时间:2022-05-24
下一篇:
C# DbSkipExpression类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap