using System;
using System.Xml;
using System.Xml.Serialization;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Diagnostics;
using System.Runtime;
using System.Runtime.Serialization;
using Tdo;
using Tdo.Common;
using Tdo.Common.Entities;
using Tdo.Common.Entities.Tables;
using Tdo.Common.Entities.Views;
using Tdo.Common.Helper;
using Tdo.Common.TdoSqlExpressionDom;
using Tdo.Common.TdoTypes;
namespace Tdo.Common.TdoSqlExpressionDom{
/// <summary>
/// Order By Operator enum
/// </summary>
[CLSCompliant(true)]
[Serializable()]
public enum OrderByOperator
{
/// <summary>
/// ASC Operator for Order by clause
/// </summary>
Asc,
/// <summary>
/// DESC Operator for Order by clause
/// </summary>
Desc,
}
/// <summary>
/// SqlOperator enumeration.
/// </summary>
[CLSCompliant(true)]
[Serializable()]
public enum SqlOperator
{
/// <summary>
/// Boolean And operator
/// </summary>
And,
/// <summary>
/// Boolean Or operator
/// </summary>
Or,
/// <summary>
/// Boolean Not
/// </summary>
Not,
/// <summary>
/// Boolean Not And operator
/// </summary>
NotAnd,
/// <summary>
/// Boolean Not Or operator
/// </summary>
NotOr,
/// <summary>
/// Boolean Exclusive Or operator
/// </summary>
ExclusiveOr,
/// <summary>
/// Boolean Lower than operator
/// </summary>
Lower,
/// <summary>
/// Boolean Lower or equal than operator
/// </summary>
LowerOrEqual,
/// <summary>
/// Greater than operator
/// </summary>
Greater,
/// <summary>
/// Greater or equal than operator
/// </summary>
GreaterOrEqual,
/// <summary>
/// Equality operator.
/// </summary>
Equal,
/// <summary>
/// Unequality operator.
/// </summary>
NotEqual,
/// <summary>
/// Sql In operator.
/// </summary>
In,
/// <summary>
/// Sql Not In operator.
/// </summary>
NotIn,
/// <summary>
/// Sql Between operator.
/// </summary>
Between,
/// <summary>
/// Sql Not Between operator.
/// </summary>
NotBetween,
/// <summary>
/// Sql Like operator.
/// </summary>
Like,
/// <summary>
/// Sql Not Like or unlike operator.
/// </summary>
NotLike,
/// <summary>
/// Is operator
/// </summary>
Is,
/// <summary>
/// Is Not operator
/// </summary>
IsNot,
}
/// <summary>
/// SqlOperator enumeration class wrapper.
/// </summary>
[Serializable()]
internal sealed class SqlOperatorHelper
{
private SqlOperator cmpOp;
/// <summary>
/// Returns Hash actualValue
/// </summary>
/// <returns> </returns>
public override int GetHashCode()
{
int retval = cmpOp.GetHashCode();
return retval;
}
/// <summary>
/// default constructor.
/// </summary>
internal SqlOperatorHelper()
{
cmpOp = SqlOperator.Equal;
}
/// <summary>
/// initialize with compare logical operator
/// </summary>
/// <param name="op"></param>
internal SqlOperatorHelper(SqlOperator op)
{
cmpOp = op;
}
/// <summary>
/// initialize with join logical operator
/// </summary>
/// <param name="op"></param>
internal SqlOperatorHelper(JoinOperator op)
{
switch (op)
{
case (JoinOperator.Lower): this.cmpOp = SqlOperator.Lower; break;
case (JoinOperator.LowerOrEqual): this.cmpOp = SqlOperator.LowerOrEqual; break;
case (JoinOperator.Greater): this.cmpOp = SqlOperator.Greater; break;
case (JoinOperator.GreaterOrEqual): this.cmpOp = SqlOperator.GreaterOrEqual; break;
case (JoinOperator.Equal): this.cmpOp = SqlOperator.Equal; break;
case (JoinOperator.NotEqual): this.cmpOp = SqlOperator.NotEqual; break;
}
}
/// <summary>
/// implicit SqlOperatorHelper type constructor from SqlOperator enumeration.
/// </summary>
/// <param name="op">SqlOperator enumeration actualValue type.</param>
/// <returns>returns new SqlOperatorHelper class wrapper.</returns>
public static implicit operator SqlOperatorHelper(SqlOperator op)
{
return new SqlOperatorHelper(op);
}
/// <summary>
/// copy constructor for SqlOperatorHelper class.
/// </summary>
/// <param name="op">SqlOperatorHelper class to copy from.</param>
internal SqlOperatorHelper(SqlOperatorHelper op)
{
cmpOp = op.cmpOp;
}
/// <summary>
/// converts implicitly from a compareOperator type to a string
/// </summary>
/// <param name="op">the operator enum type to convert in clear string</param>
/// <returns>Returns an expression as TdoSqlExpression useful to convert the Where Clause in string type</returns>
public static implicit operator string(SqlOperatorHelper op)
{
switch (op.cmpOp)
{
case SqlOperator.Lower:
return "<";
case SqlOperator.LowerOrEqual:
return "<=";
case SqlOperator.Greater:
return ">";
case SqlOperator.GreaterOrEqual:
return ">=";
case SqlOperator.Equal:
return "=";
case SqlOperator.NotEqual:
return "<>";
case SqlOperator.Like:
return "LIKE";
case SqlOperator.NotLike:
return "NOT LIKE";
case SqlOperator.And:
return "AND";
case SqlOperator.Or:
return "OR";
case SqlOperator.Not:
return "NOT";
case SqlOperator.NotAnd:
return "NOT AND";
case SqlOperator.NotOr:
return "NOR";
case SqlOperator.ExclusiveOr:
return "XOR";
case SqlOperator.NotBetween:
return "NOT BETWEEN";
case SqlOperator.Between:
return "BETWEEN";
case SqlOperator.In:
return "IN";
case SqlOperator.NotIn:
return "NOT IN";
case SqlOperator.Is:
return "IS";
case SqlOperator.IsNot:
return "IS NOT";
default:
return "";
}
}
}
}
|