本文整理汇总了C#中ISqlObject类的典型用法代码示例。如果您正苦于以下问题:C# ISqlObject类的具体用法?C# ISqlObject怎么用?C# ISqlObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ISqlObject类属于命名空间,在下文中一共展示了ISqlObject类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ConvertTo
public override object ConvertTo(ISqlObject obj, Type destType)
{
if (obj == null || obj.IsNull)
return null;
throw new InvalidCastException();
}
开发者ID:furesoft,项目名称:deveeldb,代码行数:7,代码来源:NullType.cs
示例2: Add
public override ISqlObject Add(ISqlObject a, ISqlObject b)
{
if (!(a is SqlNumber))
throw new ArgumentException();
if (b is SqlNull || b.IsNull)
return SqlNumber.Null;
var num1 = (SqlNumber) a;
SqlNumber num2;
if (b is SqlBoolean) {
if ((SqlBoolean) b) {
num2 = SqlNumber.One;
} else if (!(SqlBoolean) b) {
num2 = SqlNumber.Zero;
} else {
num2 = SqlNumber.Null;
}
} else if (b is SqlNumber) {
num2 = (SqlNumber) b;
} else {
throw new ArgumentException();
}
return num1.Add(num2);
}
开发者ID:deveel,项目名称:deveeldb,代码行数:26,代码来源:NumericType.cs
示例3: And
public override ISqlObject And(ISqlObject a, ISqlObject b)
{
if (a.IsNull || b.IsNull)
return SqlBoolean.Null;
var b1 = (SqlBoolean) a;
var b2 = (SqlBoolean) b;
return b1.And(b2);
}
开发者ID:ArsenShnurkov,项目名称:deveeldb,代码行数:10,代码来源:BooleanType.cs
示例4: SerializeObject
public override void SerializeObject(Stream stream, ISqlObject obj)
{
var writer = new BinaryWriter(stream);
if (obj is SqlNull) {
writer.Write((byte)1);
} else if (obj == null || obj.IsNull) {
writer.Write((byte) 2);
} else {
throw new FormatException();
}
}
开发者ID:furesoft,项目名称:deveeldb,代码行数:12,代码来源:NullType.cs
示例5: BuildName
public string BuildName(ISqlObject sqlObject)
{
var sb = new StringBuilder();
var schemaMember = sqlObject as ISchemaMember;
if (schemaMember != null)
{
sb.Append(GetSchemaNameSql(schemaMember))
.Append(".");
}
sb.Append(keywordEncoder.Encode(sqlObject.Name));
return sb.ToString();
}
开发者ID:footcha,项目名称:DbTracer,代码行数:13,代码来源:FullNameWithSchemaBuilder.cs
示例6: QueryResultRow
public QueryResultRow(ISqlObject[] values, int[] valueSizes)
{
if (values == null)
throw new ArgumentNullException("values");
if (valueSizes == null)
throw new ArgumentNullException("valueSizes");
if (values.Length != valueSizes.Length)
throw new ArgumentException();
Values = values;
ValueSizes = valueSizes;
}
开发者ID:deveel,项目名称:deveeldb,代码行数:13,代码来源:QueryResultRow.cs
示例7: ConvertTo
public override object ConvertTo(ISqlObject obj, Type destType)
{
var xmlNode = obj as SqlXmlNode;
if (xmlNode == null || xmlNode.IsNull)
return null;
if (destType == typeof (string))
return xmlNode.ToString();
if (destType == typeof (XmlNode))
return xmlNode.ToXmlNode();
if (destType == typeof (byte[]))
return xmlNode.ToBytes();
return base.ConvertTo(obj, destType);
}
开发者ID:ArsenShnurkov,项目名称:deveeldb,代码行数:15,代码来源:XmlNodeType.cs
示例8: QueryParameter
public QueryParameter(string name, SqlType sqlType, ISqlObject value)
{
if (sqlType == null)
throw new ArgumentNullException("sqlType");
if (String.IsNullOrEmpty(name))
throw new ArgumentNullException("name");
if (!String.Equals(name, Marker, StringComparison.Ordinal) &&
name[0] != NamePrefix)
throw new ArgumentException(String.Format("The parameter name '{0}' is invalid: must be '{1}' or starting with '{2}'", name, Marker, NamePrefix));
Name = name;
SqlType = sqlType;
Value = value;
Direction = QueryParameterDirection.In;
}
开发者ID:furesoft,项目名称:deveeldb,代码行数:17,代码来源:QueryParameter.cs
示例9: SerializeObject
public override void SerializeObject(Stream stream, ISqlObject obj)
{
var writer = new BinaryWriter(stream, Encoding.Unicode);
var queryPlanObj = (SqlQueryObject) obj;
if (queryPlanObj.IsNull) {
writer.Write((byte) 0);
} else {
writer.Write((byte)1);
var nodeTypeString = queryPlanObj.QueryPlan.GetType().AssemblyQualifiedName;
if (String.IsNullOrEmpty(nodeTypeString))
throw new InvalidOperationException();
writer.Write(nodeTypeString);
SerializePlan(queryPlanObj.QueryPlan, writer);
}
}
开发者ID:ArsenShnurkov,项目名称:deveeldb,代码行数:17,代码来源:QueryType.cs
示例10: CastTo
public override ISqlObject CastTo(ISqlObject value, SqlType destType)
{
var sqlType = destType.TypeCode;
var binary = ((ISqlBinary) value);
ISqlObject casted;
switch (sqlType) {
case SqlTypeCode.Bit:
case SqlTypeCode.Boolean:
casted = ToBoolean(binary);
break;
// TODO: All other casts
default:
throw new InvalidCastException();
}
return casted;
}
开发者ID:deveel,项目名称:deveeldb,代码行数:19,代码来源:BinaryType.cs
示例11: QueryParameter
public QueryParameter(string name, SqlType sqlType, ISqlObject value)
{
if (sqlType == null)
throw new ArgumentNullException("sqlType");
if (String.IsNullOrEmpty(name))
throw new ArgumentNullException("name");
if (!String.Equals(name, Marker, StringComparison.Ordinal) &&
name[0] == NamePrefix) {
name = name.Substring(1);
if (String.IsNullOrEmpty(name))
throw new ArgumentException("Cannot specify only the variable bind prefix as parameter.");
}
Name = name;
SqlType = sqlType;
Value = value;
Direction = QueryParameterDirection.In;
}
开发者ID:deveel,项目名称:deveeldb,代码行数:21,代码来源:QueryParameter.cs
示例12: CastTo
public override ISqlObject CastTo(ISqlObject value, SqlType destType)
{
var bValue = ((SqlBoolean) value);
if (destType is StringType) {
if (bValue.IsNull)
return SqlString.Null;
string s;
if (TypeCode == SqlTypeCode.Bit) {
s = bValue ? "1" : "0";
} else {
s = bValue ? "true" : "false";
}
return new SqlString(s);
}
if (destType is NumericType) {
SqlNumber num;
if (bValue == SqlBoolean.Null) {
num = SqlNumber.Null;
} else if (bValue) {
num = SqlNumber.One;
} else {
num = SqlNumber.Zero;
}
return num;
}
if (destType is BinaryType) {
var bytes = new[] {bValue ? (byte)1 : (byte)0};
return new SqlBinary(bytes);
}
if (destType is BooleanType)
return value;
return base.CastTo(value, destType);
}
开发者ID:deveel,项目名称:deveeldb,代码行数:38,代码来源:BooleanType.cs
示例13: IsSmallerThan
public override SqlBoolean IsSmallerThan(ISqlObject a, ISqlObject b)
{
if (!(a is SqlNumber) ||
!(b is SqlNumber))
throw new ArgumentException();
if (b.IsNull)
return SqlBoolean.Null;
if (a.IsNull)
return SqlBoolean.Null;
var num1 = (SqlNumber) a;
var num2 = (SqlNumber) b;
return num1 < num2;
}
开发者ID:deveel,项目名称:deveeldb,代码行数:17,代码来源:NumericType.cs
示例14: IsNotEqualTo
public override SqlBoolean IsNotEqualTo(ISqlObject a, ISqlObject b)
{
return !IsEqualTo(a, b);
}
开发者ID:deveel,项目名称:deveeldb,代码行数:4,代码来源:NumericType.cs
示例15: IsEqualTo
public override SqlBoolean IsEqualTo(ISqlObject a, ISqlObject b)
{
if (!(a is SqlNumber) ||
!(b is SqlNumber))
throw new ArgumentException();
if (b.IsNull)
return a.IsNull;
if (a.IsNull)
return b.IsNull;
var num1 = (SqlNumber) a;
var num2 = (SqlNumber) b;
return num1.Equals(num2);
}
开发者ID:deveel,项目名称:deveeldb,代码行数:17,代码来源:NumericType.cs
示例16: ConvertTo
public override object ConvertTo(ISqlObject obj, Type destType)
{
if (!(obj is SqlNumber))
throw new ArgumentException();
var number = (SqlNumber)obj;
if (number.IsNull)
return null;
if (destType == typeof(byte))
return number.ToByte();
if (destType == typeof(short))
return number.ToInt16();
if (destType == typeof(int))
return number.ToInt32();
if (destType == typeof(long))
return number.ToInt64();
if (destType == typeof(float))
return number.ToSingle();
if (destType == typeof(double))
return number.ToDouble();
if (destType == typeof(bool))
return number.ToBoolean();
if (destType == typeof(string))
return number.ToString();
return base.ConvertTo(obj, destType);
}
开发者ID:deveel,项目名称:deveeldb,代码行数:30,代码来源:NumericType.cs
示例17: Compare
public override int Compare(ISqlObject x, ISqlObject y)
{
var n1 = (SqlNumber)x;
SqlNumber n2;
if (y is SqlNumber) {
n2 = (SqlNumber)y;
} else if (y is SqlBoolean) {
n2 = (SqlBoolean) y ? SqlNumber.One : SqlNumber.Zero;
} else {
throw new NotSupportedException();
}
return n1.CompareTo(n2);
}
开发者ID:deveel,项目名称:deveeldb,代码行数:15,代码来源:NumericType.cs
示例18: CastTo
public override ISqlObject CastTo(ISqlObject value, SqlType destType)
{
var n = (SqlNumber) value;
var sqlType = destType.TypeCode;
ISqlObject casted;
switch (sqlType) {
case (SqlTypeCode.Bit):
case (SqlTypeCode.Boolean):
casted = new SqlBoolean(n.ToBoolean());
break;
case (SqlTypeCode.TinyInt):
case (SqlTypeCode.SmallInt):
case (SqlTypeCode.Integer):
casted = new SqlNumber(n.ToInt32());
break;
case (SqlTypeCode.BigInt):
casted = new SqlNumber(n.ToInt64());
break;
case (SqlTypeCode.Float):
case (SqlTypeCode.Real):
case (SqlTypeCode.Double):
double d;
if (n.State == NumericState.NotANumber) {
casted = new SqlNumber(Double.NaN);
} else if (n.State == NumericState.PositiveInfinity) {
casted = new SqlNumber(Double.PositiveInfinity);
} else if (n.State == NumericState.NegativeInfinity) {
casted = new SqlNumber(Double.NegativeInfinity);
} else {
casted = new SqlNumber(n.ToDouble());
}
break;
case (SqlTypeCode.Numeric):
case (SqlTypeCode.Decimal):
casted = n;
break;
case (SqlTypeCode.Char):
casted = new SqlString(n.ToString().PadRight(((StringType) destType).MaxSize));
break;
case (SqlTypeCode.VarChar):
case (SqlTypeCode.LongVarChar):
case (SqlTypeCode.String):
casted = new SqlString(n.ToString());
break;
case (SqlTypeCode.Date):
case (SqlTypeCode.Time):
case (SqlTypeCode.TimeStamp):
casted = ToDate(n.ToInt64());
break;
case (SqlTypeCode.Blob):
case (SqlTypeCode.Binary):
case (SqlTypeCode.VarBinary):
case (SqlTypeCode.LongVarBinary):
casted = new SqlBinary(n.ToByteArray());
break;
case (SqlTypeCode.Null):
casted = SqlNull.Value;
break;
default:
throw new InvalidCastException();
}
return casted;
}
开发者ID:deveel,项目名称:deveeldb,代码行数:66,代码来源:NumericType.cs
示例19: SerializeObject
public override void SerializeObject(Stream stream, ISqlObject obj)
{
var writer = new BinaryWriter(stream);
if (obj is SqlNull) {
writer.Write((byte) 0);
} else {
var date = (SqlDateTime) obj;
if (date.IsNull) {
writer.Write((byte)0);
} else {
var bytes = date.ToByteArray(true);
writer.Write((byte)1);
writer.Write(bytes.Length);
writer.Write(bytes);
}
}
}
开发者ID:ArsenShnurkov,项目名称:deveeldb,代码行数:20,代码来源:DateType.cs
示例20: XOr
public override ISqlObject XOr(ISqlObject a, ISqlObject b)
{
if (!(a is SqlNumber) ||
!(b is SqlNumber))
throw new ArgumentException();
if (b.IsNull)
return SqlNumber.Null;
if (a.IsNull)
return a;
var num1 = (SqlNumber) a;
var num2 = (SqlNumber) b;
return num1.XOr(num2);
}
开发者ID:deveel,项目名称:deveeldb,代码行数:17,代码来源:NumericType.cs
注:本文中的ISqlObject类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论