本文整理汇总了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";
}
}
示例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();
}
}
示例3: CouchBase
protected CouchBase(string username, string password, AuthenticationType aT, DbType dbType)
{
this.username = username;
this.password = password;
this.authType = aT;
this.dbType = dbType;
}
示例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;
}
示例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);
}
}
示例6: Parameters
public Parameters(string Name, object Value,DbType dbType)
{
ParamName = Name;
ParamValue = Value;
ParamDbType = dbType;
ParamDirection = ParameterDirection.Input;
}
示例7: DBMapping
public DBMapping(string first, string second, DbType type, int size)
{
this._first = first;
this._second = second;
this._type = type;
this._size = size;
}
示例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);
}
示例9: RelationalTypeMapping
public RelationalTypeMapping([NotNull] string defaultTypeName, DbType? storeType = null)
{
Check.NotEmpty(defaultTypeName, nameof(defaultTypeName));
DefaultTypeName = defaultTypeName;
StoreType = storeType;
}
示例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);
}
示例11: Column
public Column(string name, DbType type)
{
ColumnName = name;
IsAutoIncrement = false;
Type = type;
IsNullable = true;
}
示例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;
}
示例13: ExtendedProperty
public ExtendedProperty(string name, object value, DbType dataType, PropertyStateEnum state)
{
this.name = name;
this.value = value;
this.dataType = dataType;
this.propertyState = state;
}
示例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");
}
示例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;
}
}