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


C# NpgsqlDbType类代码示例

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


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

示例1: Returns

 public static NpgsqlCommand Returns(this NpgsqlCommand command, string name, NpgsqlDbType type)
 {
     var parameter = command.AddParameter(name);
     parameter.NpgsqlDbType = type;
     parameter.Direction = ParameterDirection.ReturnValue;
     return command;
 }
开发者ID:bojanv91,项目名称:Marten,代码行数:7,代码来源:CommandExtensions.cs

示例2: EnumIsOneOfWhereFragment

        public EnumIsOneOfWhereFragment(object values, EnumStorage enumStorage, string locator)
        {
            var array = values.As<Array>();
            if (enumStorage == EnumStorage.AsInteger)
            {
                var numbers = new int[array.Length];

                for (int i = 0; i < array.Length; i++)
                {
                    numbers[i] = array.GetValue(i).As<int>();
                }

                _values = numbers;
                _dbType = NpgsqlDbType.Integer | NpgsqlDbType.Array;
            }
            else
            {
                var strings = new string[array.Length];

                for (int i = 0; i < array.Length; i++)
                {
                    strings[i] = array.GetValue(i).ToString();
                }

                _values = strings;
                _dbType = NpgsqlDbType.Varchar | NpgsqlDbType.Array;
            }

            _locator = locator;
        }
开发者ID:danielmarbach,项目名称:marten,代码行数:30,代码来源:IsOneOf.cs

示例3: GetNativeTypeInfo

        /// <summary>
        /// Find a NpgsqlNativeTypeInfo in the default types map that can handle objects
        /// of the given NpgsqlDbType.
        /// </summary>
        public static NpgsqlNativeTypeInfo GetNativeTypeInfo(NpgsqlDbType NpgsqlDbType)
        {
            NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "GetBackendTypeNameFromNpgsqlDbType");

            VerifyDefaultTypesMap();
            return NativeTypeMapping[NpgsqlDbType];
        }
开发者ID:nlhepler,项目名称:mono,代码行数:11,代码来源:NpgsqlTypesHelper.cs

示例4: PostgresqlType

 public PostgresqlType(string postgresqlColumnType, string infoSchemaName, NpgsqlDbType postgresqlDbType, DbType databaseType, MungTypeCode code)
 {
     InfoSchemaName = infoSchemaName;
     CreateColumnDefinition = postgresqlColumnType;
     PostgresqlDbType = postgresqlDbType;
     DatabaseType = databaseType;
     MungType = MungType.Get(code);
 }
开发者ID:GrowingData,项目名称:Utilities,代码行数:8,代码来源:PostgresqlTypeConverter.cs

示例5: AddParameter

        public NpgsqlParameter AddParameter(object value, NpgsqlDbType dbType)
        {
            var name = "p" + _counter++;
            var param = Command.AddParameter(name, value);
            param.NpgsqlDbType = dbType;

            return param;
        }
开发者ID:danielmarbach,项目名称:marten,代码行数:8,代码来源:BatchCommand.cs

示例6: Param

        public SprocCall Param(string argName, object value, NpgsqlDbType dbType)
        {
            var param = _parent.AddParameter(value, dbType);

            _parameters.Add(new ParameterArg(argName, param));

            return this;
        }
开发者ID:danielmarbach,项目名称:marten,代码行数:8,代码来源:SprocCall.cs

示例7: MakeParameter

        public static NpgsqlParameter MakeParameter(string paramName, string value, NpgsqlDbType dbType, ParameterDirection direction)
        {
            NpgsqlParameter param = new NpgsqlParameter(":" + paramName, dbType);
            param.Direction = direction;
            param.SourceColumn = paramName;
            param.Value = value;

            return param;
        }
开发者ID:Koichi-Kobayashi,项目名称:AipoReminder,代码行数:9,代码来源:DBUtility.cs

示例8: With

        public static NpgsqlCommand With(this NpgsqlCommand command, string name, object value, NpgsqlDbType dbType)
        {
            var parameter = command.CreateParameter();
            parameter.ParameterName = name;
            parameter.Value = value ?? DBNull.Value;
            parameter.NpgsqlDbType = dbType;
            command.Parameters.Add(parameter);

            return command;
        }
开发者ID:bojanv91,项目名称:Marten,代码行数:10,代码来源:CommandExtensions.cs

示例9: TypeMappingAttribute

        /// <summary>
        /// Maps an Npgsql type handler to a PostgreSQL type.
        /// </summary>
        /// <param name="pgName">A PostgreSQL type name as it appears in the pg_type table.</param>
        /// <param name="npgsqlDbType">
        /// A member of <see cref="NpgsqlDbType"/> which represents this PostgreSQL type.
        /// An <see cref="NpgsqlParameter"/> with <see cref="NpgsqlParameter.NpgsqlDbType"/> set to
        /// this value will be sent with the type handler mapped by this attribute.
        /// </param>
        /// <param name="dbTypes">
        /// All members of <see cref="DbType"/> which represent this PostgreSQL type.
        /// An <see cref="NpgsqlParameter"/> with <see cref="NpgsqlParameter.DbType"/> set to
        /// one of these values will be sent with the type handler mapped by this attribute.
        /// </param>
        /// <param name="clrTypes">
        /// Any .NET type which corresponds to this PostgreSQL type.
        /// An <see cref="NpgsqlParameter"/> with <see cref="NpgsqlParameter.Value"/> set to
        /// one of these values will be sent with the type handler mapped by this attribute.
        /// </param>
        /// <param name="inferredDbType">
        /// The "primary" <see cref="DbType"/> which best corresponds to this PostgreSQL type.
        /// When <see cref="NpgsqlParameter.NpgsqlDbType"/> or <see cref="NpgsqlParameter.Value"/>
        /// set, <see cref="NpgsqlParameter.DbType"/> will be set to this value.
        /// </param>
        internal TypeMappingAttribute(string pgName, NpgsqlDbType? npgsqlDbType, [CanBeNull] DbType[] dbTypes, [CanBeNull] Type[] clrTypes, DbType? inferredDbType)
        {
            if (String.IsNullOrWhiteSpace(pgName))
                throw new ArgumentException("pgName can't be empty", nameof(pgName));
            Contract.EndContractBlock();

            PgName = pgName;
            NpgsqlDbType = npgsqlDbType;
            DbTypes = dbTypes ?? new DbType[0];
            ClrTypes = clrTypes ?? new Type[0];
            InferredDbType = inferredDbType;
        }
开发者ID:ArsenShnurkov,项目名称:npgsql,代码行数:36,代码来源:TypeMappingAttribute.cs

示例10: AddParameter

		/// <summary>
		/// Adds parameter to Sql Command.
		/// </summary>
		/// <param name="name">Parameter name.</param>
		/// <param name="dbType">Parameter datatype.</param>
		/// <param name="value">Parameter value.</param>
		public void AddParameter(string name,NpgsqlDbType dbType,object value)
		{		
            /*
			SqlDbType dbTyp = dbType;
			object val = value;
			
			if(dbType == SqlDbType.UniqueIdentifier){
				dbTyp = SqlDbType.NVarChar;
				string guid = val.ToString();
				if(guid.Length < 1){
					return;
				}
			}*/

			m_SqlCmd.Parameters.Add(name,dbType).Value = value;
		}
开发者ID:dioptre,项目名称:nkd,代码行数:22,代码来源:WSqlCommand.cs

示例11: NpgsqlBackendTypeInfo

        /// <summary>
        /// Construct a new NpgsqlTypeInfo with the given attributes and conversion handlers.
        /// </summary>
        /// <param name="OID">Type OID provided by the backend server.</param>
        /// <param name="Name">Type name provided by the backend server.</param>
        /// <param name="NpgsqlDbType">NpgsqlDbType</param>
        /// <param name="DbType">DbType</param>
        /// <param name="Type">System type to convert fields of this type to.</param>
        /// <param name="ConvertBackendTextToNative">Data conversion handler for text encoding.</param>
        /// <param name="ConvertBackendBinaryToNative">Data conversion handler for binary data.</param>
        public NpgsqlBackendTypeInfo(Int32 OID, String Name, NpgsqlDbType NpgsqlDbType, DbType DbType, Type Type,
                                        ConvertBackendTextToNativeHandler ConvertBackendTextToNative = null,
                                        ConvertBackendBinaryToNativeHandler ConvertBackendBinaryToNative = null)
        {
            if (Type == null)
            {
                throw new ArgumentNullException("Type");
            }

            _OID = OID;
            _Name = Name;
            _NpgsqlDbType = NpgsqlDbType;
            _DbType = DbType;
            _Type = Type;
            _frameworkType = Type;
            _ConvertBackendTextToNative = ConvertBackendTextToNative;
            _ConvertBackendBinaryToNative = ConvertBackendBinaryToNative;
        }
开发者ID:herqueles3,项目名称:Npgsql,代码行数:28,代码来源:NpgsqlTypeInfoBackend.cs

示例12: NpgsqlParameter

        /// <summary>
        /// Initializes a new instance of the <see cref="Npgsql.NpgsqlParameter">NpgsqlParameter</see>
        /// class with the parameter m_Name, the <see cref="System.Data.DbType">DbType</see>, the size,
        /// and the source column m_Name.
        /// </summary>
        /// <param m_Name="parameterName">The m_Name of the parameter to map.</param>
        /// <param m_Name="parameterType">One of the <see cref="System.Data.DbType">DbType</see> values.</param>
        /// <param m_Name="size">The length of the parameter.</param>
        /// <param m_Name="sourceColumn">The m_Name of the source column.</param>
        public NpgsqlParameter(String parameterName, NpgsqlDbType parameterType, Int32 size, String sourceColumn)
        {
            NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, CLASSNAME, parameterName, parameterType, size, source_column);

            this.ParameterName = parameterName;

            NpgsqlDbType = parameterType; //Allow the setter to catch any exceptions.

            this.size = size;
            source_column = sourceColumn;
        }
开发者ID:Qorpent,项目名称:Npgsql2,代码行数:20,代码来源:NpgsqlParameter.cs

示例13: NpgsqlParameter

        /// <summary>
        /// Initializes a new instance of the <see cref="NpgsqlParameter">NpgsqlParameter</see>.
        /// </summary>
        /// <param name="parameterName">The name of the parameter to map.</param>
        /// <param name="parameterType">One of the <see cref="NpgsqlTypes.NpgsqlDbType">NpgsqlDbType</see> values.</param>
        /// <param name="size">The length of the parameter.</param>
        /// <param name="sourceColumn">The name of the source column.</param>
        /// <param name="direction">One of the <see cref="System.Data.ParameterDirection">ParameterDirection</see> values.</param>
        /// <param name="isNullable"><b>true</b> if the value of the field can be null, otherwise <b>false</b>.</param>
        /// <param name="precision">The total number of digits to the left and right of the decimal point to which
        /// <see cref="NpgsqlParameter.Value">Value</see> is resolved.</param>
        /// <param name="scale">The total number of decimal places to which
        /// <see cref="NpgsqlParameter.Value">Value</see> is resolved.</param>
        /// <param name="sourceVersion">One of the <see cref="System.Data.DataRowVersion">DataRowVersion</see> values.</param>
        /// <param name="value">An <see cref="System.Object">Object</see> that is the value
        /// of the <see cref="NpgsqlParameter">NpgsqlParameter</see>.</param>
        public NpgsqlParameter(string parameterName, NpgsqlDbType parameterType, int size, string sourceColumn,
                               ParameterDirection direction, bool isNullable, byte precision, byte scale,
                               DataRowVersion sourceVersion, object value)
            : this()
        {
            ParameterName = parameterName;
            Size = size;
            SourceColumn = sourceColumn;
            Direction = direction;
            IsNullable = isNullable;
            Precision = precision;
            Scale = scale;
            SourceVersion = sourceVersion;
            Value = value;

            NpgsqlDbType = parameterType;
        }
开发者ID:rwrz,项目名称:npgsql,代码行数:33,代码来源:NpgsqlParameter.cs

示例14: PgsqlDbType2DbType

			public static DbType PgsqlDbType2DbType(NpgsqlDbType pgsqlDbType_in) {
				switch (pgsqlDbType_in) {
					case NpgsqlDbType.Bigint:
						return DbType.Int64;
					case NpgsqlDbType.Integer:
						return DbType.Int32;
					case NpgsqlDbType.Smallint:
						return DbType.Int16;
					case NpgsqlDbType.Boolean:
						return DbType.Boolean;

					case NpgsqlDbType.Varchar:
					case NpgsqlDbType.Text:
						return DbType.String;

					case NpgsqlDbType.TimestampTZ:
					case NpgsqlDbType.Timestamp:
						return DbType.DateTime;

					case NpgsqlDbType.Real:
						return DbType.Single;
					case NpgsqlDbType.Double:
						return DbType.Double;
					case NpgsqlDbType.Numeric:
						return DbType.Decimal;
					case NpgsqlDbType.Bytea:
						return DbType.Binary;
					case NpgsqlDbType.Date:
						return DbType.Date;
					case NpgsqlDbType.Time:
						return DbType.Time;
					case NpgsqlDbType.Money:
						return DbType.Decimal;

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

示例15: AddType

 /// <summary>
 /// Add a new NpgsqlBackendTypeInfo with the given attributes and conversion handlers to this mapping.
 /// </summary>
 /// <param name="OID">Type OID provided by the backend server.</param>
 /// <param name="Name">Type name provided by the backend server.</param>
 /// <param name="NpgsqlDbType">NpgsqlDbType</param>
 /// <param name="DbType">DbType</param>
 /// <param name="Type">System type to convert fields of this type to.</param>
 /// <param name="BackendTextConvert">Data conversion handler for text encoding.</param>
 /// <param name="BackendBinaryConvert">Data conversion handler for binary data.</param>
 public void AddType(Int32 OID, String Name, NpgsqlDbType NpgsqlDbType, DbType DbType, Type Type,
                     ConvertBackendTextToNativeHandler BackendTextConvert = null,
                     ConvertBackendBinaryToNativeHandler BackendBinaryConvert = null)
 {
     AddType(new NpgsqlBackendTypeInfo(OID, Name, NpgsqlDbType, DbType, Type, BackendTextConvert = null, BackendBinaryConvert = null));
 }
开发者ID:herqueles3,项目名称:Npgsql,代码行数:16,代码来源:NpgsqlTypeMappings.cs


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