SqlOperatorHelper.cs :  » Database » TDO » Tdo » Common » TdoSqlExpressionDom » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Database » TDO 
TDO » Tdo » Common » TdoSqlExpressionDom » SqlOperatorHelper.cs
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 "";
      }
    }
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.