本文整理汇总了C#中ISqlObject类的典型用法代码示例。如果您正苦于以下问题:C# ISqlObject类的具体用法?C# ISqlObject怎么用?C# ISqlObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ISqlObject类属于命名空间,在下文中一共展示了ISqlObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertTo
public override object ConvertTo(ISqlObject obj, Type destType)
{
if (obj == null || obj.IsNull)
return null;
throw new InvalidCastException();
}
示例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);
}
示例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);
}
示例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();
}
}
示例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();
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例14: IsNotEqualTo
public override SqlBoolean IsNotEqualTo(ISqlObject a, ISqlObject b)
{
return !IsEqualTo(a, b);
}
示例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);
}