本文整理汇总了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;
}
示例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;
}
示例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];
}
示例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);
}
示例5: AddParameter
public NpgsqlParameter AddParameter(object value, NpgsqlDbType dbType)
{
var name = "p" + _counter++;
var param = Command.AddParameter(name, value);
param.NpgsqlDbType = dbType;
return param;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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
}
}
示例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));
}