本文整理汇总了C#中NpgsqlDbType类的典型用法代码示例。如果您正苦于以下问题:C# NpgsqlDbType类的具体用法?C# NpgsqlDbType怎么用?C# NpgsqlDbType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NpgsqlDbType类属于命名空间,在下文中一共展示了NpgsqlDbType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: InsertValue
public void InsertValue(DbType? dbType, NpgsqlDbType? npgsqlDbType, string fieldName, object value)
{
if (dbType.HasValue && npgsqlDbType.HasValue || (!dbType.HasValue && !npgsqlDbType.HasValue))
Assert.Fail("Exactly one of dbType and npgsqlDbType must be specified");
using (var command = new NpgsqlCommand(String.Format("INSERT INTO data ({0}) values (:a)", fieldName), Conn))
{
if (dbType.HasValue)
command.Parameters.Add(new NpgsqlParameter("a", dbType.Value));
else
command.Parameters.Add(new NpgsqlParameter("a", npgsqlDbType.Value));
command.Parameters[0].Value = value;
var rowsAdded = command.ExecuteNonQuery();
Assert.AreEqual(1, rowsAdded);
}
var result = ExecuteScalar(String.Format("SELECT {0} FROM data", fieldName));
Assert.AreEqual(value, result);
}
开发者ID:baondp,项目名称:Npgsql,代码行数:19,代码来源:CommandTests.cs
示例17: 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)
{
this.ParameterName = parameterName;
NpgsqlDbType = parameterType; //Allow the setter to catch any exceptions.
this.size = size;
source_column = sourceColumn;
}
开发者ID:dstimac,项目名称:revenj,代码行数:18,代码来源:NpgsqlParameter.cs
示例18: AddWithValue
/// <summary>
/// Adds a <see cref="Npgsql.NpgsqlParameter">NpgsqlParameter</see> to the <see cref="Npgsql.NpgsqlParameterCollection">NpgsqlParameterCollection</see> given the specified parameter name and value.
/// </summary>
/// <param name="parameterName">The name of the <see cref="Npgsql.NpgsqlParameter">NpgsqlParameter</see>.</param>
/// <param name="value">The Value of the <see cref="Npgsql.NpgsqlParameter">NpgsqlParameter</see> to add to the collection.</param>
/// <param name="parameterType">One of the NpgsqlDbType values.</param>
/// <param name="size">The length of the column.</param>
/// <param name="sourceColumn">The name of the source column.</param>
/// <returns>The paramater that was added.</returns>
public NpgsqlParameter AddWithValue(string parameterName, NpgsqlDbType parameterType, int size, string sourceColumn, object value)
{
NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "AddWithValue", parameterName, parameterType, size, sourceColumn, value);
NpgsqlParameter param = new NpgsqlParameter(parameterName, parameterType, size, sourceColumn);
param.Value = value;
return this.Add(param);
}
开发者ID:undeadlabs,项目名称:Npgsql,代码行数:19,代码来源:NpgsqlParameterCollection.cs
示例19: Add
/// <summary>
/// Adds a <see cref="Npgsql.NpgsqlParameter">NpgsqlParameter</see> to the <see cref="Npgsql.NpgsqlParameterCollection">NpgsqlParameterCollection</see> given the parameter name and the data type.
/// </summary>
/// <param name="parameterName">The name of the parameter.</param>
/// <param name="parameterType">One of the DbType values.</param>
/// <returns>The index of the new <see cref="Npgsql.NpgsqlParameter">NpgsqlParameter</see> object.</returns>
public NpgsqlParameter Add(string parameterName, NpgsqlDbType parameterType)
{
NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "Add", parameterName, parameterType);
return this.Add(new NpgsqlParameter(parameterName, parameterType));
}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:11,代码来源:NpgsqlParameterCollection.cs
示例20: Set
void Set(string name, NpgsqlDbType type, object value)
{
if(!Command.Parameters.Contains(name))
Command.Parameters.Add(new NpgsqlParameter(name, type));
Command.Parameters[name].Value = value;
}
开发者ID:nolanlum,项目名称:MyRiotControl,代码行数:6,代码来源:SQLCommand.cs
注:本文中的NpgsqlDbType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论