本文整理汇总了C#中ConvertType类的典型用法代码示例。如果您正苦于以下问题:C# ConvertType类的具体用法?C# ConvertType怎么用?C# ConvertType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConvertType类属于命名空间,在下文中一共展示了ConvertType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Convert
public override object Convert(object value, ConvertType convertType)
{
switch (convertType)
{
case ConvertType.NameToCommandParameter:
case ConvertType.NameToSprocParameter:
return ParameterPrefix == null? value: ParameterPrefix + value;
case ConvertType.SprocParameterToName:
var name = (string)value;
if (name.Length > 0)
{
if (name[0] == ':')
return name.Substring(1);
if (ParameterPrefix != null &&
name.ToUpper(CultureInfo.InvariantCulture).StartsWith(ParameterPrefix))
{
return name.Substring(ParameterPrefix.Length);
}
}
break;
case ConvertType.ExceptionToErrorNumber:
if (value is OracleException)
return ((OracleException)value).Code;
break;
}
return SqlProvider.Convert(value, convertType);
}
示例2: Convert
public override object Convert(object value, ConvertType convertType)
{
string name = (string)value;
switch (convertType)
{
case ConvertType.NameToQueryParameter:
case ConvertType.NameToParameter:
return "@" + name;
case ConvertType.NameToQueryField:
case ConvertType.NameToQueryTable:
if (name.Length > 0 && name[0] == '[')
return value;
if (name.IndexOf('.') > 0)
value = string.Join("].[", name.Split('.'));
return "[" + value + "]";
case ConvertType.ParameterToName:
return name.Length > 0 && name[0] == '@'? name.Substring(1): name;
case ConvertType.ExceptionToErrorNumber:
if (value is SQLiteException)
return ((SQLiteException)value).ErrorCode;
break;
}
return value;
}
示例3: Convert
public override object Convert(object value, ConvertType convertType)
{
switch (convertType)
{
case ConvertType.NameToQueryField:
case ConvertType.NameToQueryTable:
if (QuoteIdentifiers)
{
string name = value.ToString();
if (name.Length > 0 && name[0] == '"')
return value;
return '"' + name + '"';
}
break;
case ConvertType.NameToQueryParameter:
case ConvertType.NameToCommandParameter:
case ConvertType.NameToSprocParameter:
return "@" + value;
case ConvertType.SprocParameterToName:
if (value != null)
{
string str = value.ToString();
return str.Length > 0 && str[0] == '@' ? str.Substring(1) : str;
}
break;
}
return value;
}
示例4: Convert
public override object Convert(object value, ConvertType convertType)
{
switch (convertType)
{
case ConvertType.NameToQueryParameter:
case ConvertType.NameToCommandParameter:
case ConvertType.NameToSprocParameter:
return "@" + value;
case ConvertType.NameToQueryField:
case ConvertType.NameToQueryFieldAlias:
case ConvertType.NameToQueryTableAlias:
{
var name = value.ToString();
if (name.Length > 0 && name[0] == '[')
return value;
}
return "[" + value + "]";
case ConvertType.NameToDatabase:
case ConvertType.NameToOwner:
case ConvertType.NameToQueryTable:
{
var name = value.ToString();
if (name.Length > 0 && name[0] == '[')
return value;
if (name.IndexOf('.') > 0)
value = string.Join("].[", name.Split('.'));
}
return "[" + value + "]";
case ConvertType.SprocParameterToName:
if (value != null)
{
var str = value.ToString();
return str.Length > 0 && str[0] == '@'? str.Substring(1): str;
}
break;
case ConvertType.ExceptionToErrorNumber:
if (value is OleDbException)
{
var ex = (OleDbException)value;
if (ex.Errors.Count > 0)
return ex.Errors[0].NativeError;
}
break;
}
return value;
}
示例5: Convert
public override object Convert(object value, ConvertType convertType)
{
switch (convertType)
{
case ConvertType.NameToQueryParameter:
case ConvertType.NameToCommandParameter:
case ConvertType.NameToSprocParameter:
{
var name = "@" + value;
if (name.Length > 27)
name = name.Substring(0, 27);
return name;
}
case ConvertType.NameToQueryField:
case ConvertType.NameToQueryFieldAlias:
case ConvertType.NameToQueryTableAlias:
{
var name = value.ToString();
if (name.Length > 28 || name.Length > 0 && name[0] == '[')
return value;
}
return "[" + value + "]";
case ConvertType.NameToDatabase:
case ConvertType.NameToOwner:
case ConvertType.NameToQueryTable:
if (value != null)
{
var name = value.ToString();
if (name.Length > 28 || name.Length > 0 && (name[0] == '[' || name[0] == '#'))
return value;
if (name.IndexOf('.') > 0)
value = string.Join("].[", name.Split('.'));
return "[" + value + "]";
}
break;
case ConvertType.SprocParameterToName:
if (value != null)
{
var str = value.ToString();
return str.Length > 0 && str[0] == '@'? str.Substring(1): str;
}
break;
}
return value;
}
示例6: Convert
public override object Convert(object value, ConvertType convertType)
{
switch (convertType)
{
case ConvertType.NameToQueryParameter:
return ":" + value;
}
return value;
}
示例7: Convert
public override object Convert(object value, ConvertType convertType)
{
switch (convertType)
{
case ConvertType.NameToQueryParameter:
case ConvertType.NameToParameter:
return "@" + value;
case ConvertType.NameToQueryField:
{
string name = value.ToString();
if (name.Length > 0 && name[0] == '[')
return value;
}
return "[" + value + "]";
case ConvertType.NameToQueryTable:
{
string name = value.ToString();
if (name.Length > 0 && name[0] == '[')
return value;
if (name.IndexOf('.') > 0)
value = string.Join("].[", name.Split('.'));
}
return "[" + value + "]";
case ConvertType.ParameterToName:
if (value != null)
{
string str = value.ToString();
return str.Length > 0 && str[0] == '@'? str.Substring(1): str;
}
break;
case ConvertType.ExceptionToErrorNumber:
if (value is AseException)
{
AseException ex = (AseException)value;
if (ex.Errors.Count > 0)
return ex.Errors[0].MessageNumber;
}
break;
}
return value;
}
示例8: Convert
public override object Convert(object value, ConvertType convertType)
{
if (ConvertType.NameToQueryField == convertType)
{
return FieldMarker + value;
}
if (ConvertType.NameToQueryTable == convertType)
{
return TableMarker + value;
}
return base.Convert(value, convertType);
}
示例9: Convert
public override object Convert(object value, ConvertType convertType)
{
switch (convertType)
{
case ConvertType.ExceptionToErrorNumber:
if (value is SqlCeException)
return ((SqlCeException)value).NativeError;
break;
}
return SqlProvider.Convert(value, convertType);
}
示例10: Convert
public override object Convert(object value, ConvertType convertType)
{
switch (convertType)
{
case ConvertType.NameToQueryParameter:
return "?";
case ConvertType.NameToParameter:
return value;
}
return base.Convert(value, convertType);
}
示例11: Convert
public override object Convert(object value, ConvertType convertType)
{
switch (convertType)
{
case ConvertType.ExceptionToErrorNumber:
{
if (value is SQLiteException)
return ((SQLiteException) value).ErrorCode;
break;
}
}
return SqlProvider.Convert(value, convertType);
}
示例12: Convert
public override object Convert(object value, ConvertType convertType)
{
switch (convertType)
{
case ConvertType.ExceptionToErrorNumber:
if (value is OdbcException)
{
OdbcException ex = (OdbcException)value;
if (ex.Errors.Count > 0)
return ex.Errors[0].NativeError;
}
break;
}
return base.Convert(value, convertType);
}
示例13: Convert
public override object Convert(object value, ConvertType convertType)
{
switch (convertType)
{
case ConvertType.NameToQueryParameter:
return "@" + value;
case ConvertType.NameToCommandParameter:
case ConvertType.NameToSprocParameter:
return ":" + value;
case ConvertType.SprocParameterToName:
if (value != null)
{
var str = value.ToString();
return str.Length > 0 && str[0] == ':'? str.Substring(1): str;
}
break;
case ConvertType.NameToQueryField:
case ConvertType.NameToQueryFieldAlias:
case ConvertType.NameToQueryTable:
case ConvertType.NameToQueryTableAlias:
if (value != null && IdentifierQuoteMode != DB2IdentifierQuoteMode.None)
{
var name = value.ToString();
if (name.Length > 0 && name[0] == '"')
return name;
if (IdentifierQuoteMode == DB2IdentifierQuoteMode.Quote ||
name.StartsWith("_") ||
name
#if NETFX_CORE
.ToCharArray()
#endif
.Any(c => char.IsLower(c) || char.IsWhiteSpace(c)))
return '"' + name + '"';
}
break;
}
return value;
}
示例14: Convert
public override object Convert(object value, ConvertType convertType)
{
switch (convertType)
{
case ConvertType.NameToQueryParameter : return "?";
case ConvertType.NameToCommandParameter :
case ConvertType.NameToSprocParameter : return ":" + value;
case ConvertType.SprocParameterToName :
if (value != null)
{
var str = value.ToString();
return (str.Length > 0 && str[0] == ':')? str.Substring(1): str;
}
break;
}
return value;
}
示例15: Convert
public override object Convert(object value, ConvertType convertType)
{
switch (convertType)
{
case ConvertType.ExceptionToErrorNumber:
if (value is NpgsqlException)
{
var ex = (NpgsqlException)value;
foreach (NpgsqlError error in ex.Errors)
return error.Code;
return 0;
}
break;
}
return SqlProvider.Convert(value, convertType);
}