JoinHelper.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 » JoinHelper.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>
  /// Join Operators
  /// </summary>
  [Serializable]
  [CLSCompliant(true)]
  public enum Join
  {
    /// <summary>
    /// INNER JOIN OPERATOR
    /// </summary>
    InnerJoin,
    /// <summary>
    /// LEFT OUTER JOIN OPERATOR
    /// </summary>
    LeftOuterJoin,
    /// <summary>
    /// RIGHT OUTER JOIN OPERATOR
    /// </summary>
    RightOuterJoin,
    /// <summary>
    /// FULL OUTER JOIN OPERATOR
    /// </summary>
    FullOuterJoin,
    /// <summary>
    /// CROSS JOIN OPERATOR
    /// </summary>
    CrossJoin
  }

  /// <summary>
  /// Provides Information for SelectJoin Method
  /// </summary>
  [CLSCompliant(true)]
  public class JoinHelper
  {
    internal ITdoEntity[] tables;
    internal Join[] joins;
    internal ITdoColumn[] fields;
    internal JoinOperator[] sqlOperators;
    internal int count;

    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1500:VariableNamesShouldNotMatchFieldNames")]
    private void Initialize(int count)
    {
      this.count = count;
      this.tables = new TdoTableBase[count * 2];
      this.joins = new Join[count];
      this.fields = new ITdoColumn[count * 2];
      this.sqlOperators = new JoinOperator[count];
    }

    /// <summary>
    /// Constructor for SelectJoin Method between 2 Tables
    /// </summary>
    /// <param name="join1">Join Type between First Table and Second Table</param>
    /// <param name="fieldON11">Column of the First Table for ON Matching</param>
    /// <param name="sqlOperator1">Sql Operator for ON Matching Join between fieldON11 and fieldON12</param>
    /// <param name="fieldON12">Column of the Second Table for ON Matching</param>
    public JoinHelper(
      Join join1,
      ITdoColumn fieldON11,
      JoinOperator sqlOperator1,
      ITdoColumn fieldON12)
    {
      this.Initialize(1);
      this.joins[0] = join1;
      this.fields[0] = fieldON11; this.tables[0] = fieldON11.TdoEntity;
      this.sqlOperators[0] = sqlOperator1;
      this.fields[1] = fieldON12; this.tables[1] = fieldON12.TdoEntity;

    }

    /// <summary>
    /// Constructor for SelectJoin Method between 3 Tables
    /// </summary>
    /// <param name="join1">Join Type between First Table and Second Table</param>
    /// <param name="fieldON11">Column of the First Table for ON Matching</param>
    /// <param name="sqlOperator1">Sql Operator for ON Matching Join between fieldON11 and fieldON12</param>
    /// <param name="fieldON12">Column of the Second Table for ON Matching</param>
    /// <param name="join2">Join Type between Second Table and Third Table</param>
    /// <param name="fieldON21">Column of the Second Table for ON Matching</param>
    /// <param name="sqlOperator2">Sql Operator for ON Matching Join between fieldON21 and fieldON22</param>
    /// <param name="fieldON22">Column of the Third Table for ON Matching</param>
    public JoinHelper(
      Join join1,
      ITdoColumn fieldON11,
      JoinOperator sqlOperator1,
      ITdoColumn fieldON12,
      Join join2,
      ITdoColumn fieldON21,
      JoinOperator sqlOperator2,
      ITdoColumn fieldON22)
    {
      this.Initialize(2);

      this.joins[0] = join1;
      this.fields[0] = fieldON11; this.tables[0] = fieldON11.TdoEntity;
      this.sqlOperators[0] = sqlOperator1;
      this.fields[1] = fieldON12; this.tables[1] = fieldON12.TdoEntity;

      this.joins[1] = join2;
      this.fields[2] = fieldON21; this.tables[2] = fieldON21.TdoEntity;
      this.sqlOperators[1] = sqlOperator2;
      this.fields[3] = fieldON22; this.tables[3] = fieldON22.TdoEntity;
    }

    /// <summary>
    /// Constructor for SelectJoin Method between 4 Tables
    /// </summary>
    /// <param name="join1">Join Type between First Table and Second Table</param>
    /// <param name="fieldON11">Column of the First Table for ON Matching</param>
    /// <param name="sqlOperator1">Sql Operator for ON Matching Join between fieldON11 and fieldON12</param>
    /// <param name="fieldON12">Column of the Second Table for ON Matching</param>
    /// <param name="join2">Join Type between Second Table and Third Table</param>
    /// <param name="fieldON21">Column of the Second Table for ON Matching</param>
    /// <param name="sqlOperator2">Sql Operator for ON Matching Join between fieldON21 and fieldON22</param>
    /// <param name="fieldON22">Column of the Third Table for ON Matching</param>
    /// <param name="join3">Join Type between Third Table and Forth Tabke</param>
    /// <param name="fieldON31">Column of the Third Table for ON Matching</param>
    /// <param name="sqlOperator3">Sql Operator for ON Matching Join between fieldON31 and fieldON32</param>
    /// <param name="fieldON32">Column of the Fourth Table for ON Matching</param>
    public JoinHelper(
      Join join1,
      ITdoColumn fieldON11,
      JoinOperator sqlOperator1,
      ITdoColumn fieldON12,
      Join join2,
      ITdoColumn fieldON21,
      JoinOperator sqlOperator2,
      ITdoColumn fieldON22,
      Join join3,
      ITdoColumn fieldON31,
      JoinOperator sqlOperator3,
      ITdoColumn fieldON32
      )
    {
      this.Initialize(3);

      this.joins[0] = join1;
      this.fields[0] = fieldON11; this.tables[0] = fieldON11.TdoEntity;
      this.sqlOperators[0] = sqlOperator1;
      this.fields[1] = fieldON12; this.tables[1] = fieldON12.TdoEntity;

      this.joins[1] = join2;
      this.fields[2] = fieldON21; this.tables[2] = fieldON21.TdoEntity;
      this.sqlOperators[1] = sqlOperator2;
      this.fields[3] = fieldON22; this.tables[3] = fieldON22.TdoEntity;

      this.joins[2] = join3;
      this.fields[4] = fieldON31; this.tables[4] = fieldON31.TdoEntity;
      this.sqlOperators[2] = sqlOperator3;
      this.fields[5] = fieldON32; this.tables[5] = fieldON32.TdoEntity;
    }

    /// <summary>
    /// Constructor for SelectJoin Method between 5 Tables
    /// </summary>
    /// <param name="join1">Join Type between First Table and Second Table</param>
    /// <param name="fieldON11">Column of the First Table for ON Matching</param>
    /// <param name="sqlOperator1">Sql Operator for ON Matching Join between fieldON11 and fieldON12</param>
    /// <param name="fieldON12">Column of the Second Table for ON Matching</param>
    /// <param name="join2">Join Type between Second Table and Third Table</param>
    /// <param name="fieldON21">Column of the Second Table for ON Matching</param>
    /// <param name="sqlOperator2">Sql Operator for ON Matching Join between fieldON21 and fieldON22</param>
    /// <param name="fieldON22">Column of the Third Table for ON Matching</param>
    /// <param name="join3">Join Type between Third Table and Fourth Tabke</param>
    /// <param name="fieldON31">Column of the Third Table for ON Matching</param>
    /// <param name="sqlOperator3">Sql Operator for ON Matching Join between fieldON31 and fieldON32</param>
    /// <param name="fieldON32">Column of the Fourth Table for ON Matching</param>
    /// <param name="join4">Join Type between Fourth Table and Fifth Tabke</param>
    /// <param name="fieldON41">Column of the Fourth Table for ON Matching</param>
    /// <param name="sqlOperator4">Sql Operator for ON Matching Join between fieldON41 and fieldON42</param>
    /// <param name="fieldON42">Column of the Fifth Table for ON Matching</param>
    public JoinHelper(
      Join join1,
      ITdoColumn fieldON11,
      JoinOperator sqlOperator1,
      ITdoColumn fieldON12,
      Join join2,
      ITdoColumn fieldON21,
      JoinOperator sqlOperator2,
      ITdoColumn fieldON22,
      Join join3,
      ITdoColumn fieldON31,
      JoinOperator sqlOperator3,
      ITdoColumn fieldON32,
      Join join4,
      ITdoColumn fieldON41,
      JoinOperator sqlOperator4,
      ITdoColumn fieldON42
      )
    {
      this.Initialize(4);

      this.joins[0] = join1;
      this.fields[0] = fieldON11; this.tables[0] = fieldON11.TdoEntity;
      this.sqlOperators[0] = sqlOperator1;
      this.fields[1] = fieldON12; this.tables[1] = fieldON12.TdoEntity;

      this.joins[1] = join2;
      this.fields[2] = fieldON21; this.tables[2] = fieldON21.TdoEntity;
      this.sqlOperators[1] = sqlOperator2;
      this.fields[3] = fieldON22; this.tables[3] = fieldON22.TdoEntity;

      this.joins[2] = join3;
      this.fields[4] = fieldON31; this.tables[4] = fieldON31.TdoEntity;
      this.sqlOperators[2] = sqlOperator3;
      this.fields[5] = fieldON32; this.tables[5] = fieldON32.TdoEntity;

      this.joins[3] = join4;
      this.fields[6] = fieldON41; this.tables[6] = fieldON41.TdoEntity;
      this.sqlOperators[3] = sqlOperator4;
      this.fields[7] = fieldON42; this.tables[7] = fieldON42.TdoEntity;
    }

    /// <summary>
    /// Constructor for SelectJoin Method between 6 Tables
    /// </summary>
    /// <param name="join1">Join Type between First Table and second Table</param>
    /// <param name="fieldON11">Column of the First Table for ON Matching</param>
    /// <param name="sqlOperator1">Sql Operator for ON Matching Join between fieldON11 and fieldON12</param>
    /// <param name="fieldON12">Column of the Second Table for ON Matching</param>
    /// <param name="join2">Join Type between Second Table and Third Table</param>
    /// <param name="fieldON21">Column of the Second Table for ON Matching</param>
    /// <param name="sqlOperator2">Sql Operator for ON Matching Join between fieldON21 and fieldON22</param>
    /// <param name="fieldON22">Column of the Third Table for ON Matching</param>
    /// <param name="join3">Join Type between Third Table and Forth Tabke</param>
    /// <param name="fieldON31">Column of the Third Table for ON Matching</param>
    /// <param name="sqlOperator3">Sql Operator for ON Matching Join between fieldON31 and fieldON32</param>
    /// <param name="fieldON32">Column of the Fourth Table for ON Matching</param>
    /// <param name="join4">Join Type between Fourth Table and Fifth Tabke</param>
    /// <param name="fieldON41">Column of the Fourth Table for ON Matching</param>
    /// <param name="sqlOperator4">Sql Operator for ON Matching Join between fieldON41 and fieldON42</param>
    /// <param name="fieldON42">Column of the Fifth Table for ON Matching</param>
    /// <param name="join5">Join Type between Fifth Table and Sixth Tabke</param>
    /// <param name="fieldON51">Column of the Fifth Table for ON Matching</param>
    /// <param name="sqlOperator5">Sql Operator for ON Matching Join between fieldON51 and fieldON52</param>
    /// <param name="fieldON52">Column of the Sixth Table for ON Matching</param>
    public JoinHelper(
      Join join1,
      ITdoColumn fieldON11,
      JoinOperator sqlOperator1,
      ITdoColumn fieldON12,
      Join join2,
      ITdoColumn fieldON21,
      JoinOperator sqlOperator2,
      ITdoColumn fieldON22,
      Join join3,
      ITdoColumn fieldON31,
      JoinOperator sqlOperator3,
      ITdoColumn fieldON32,
      Join join4,
      ITdoColumn fieldON41,
      JoinOperator sqlOperator4,
      ITdoColumn fieldON42,
      Join join5,
      ITdoColumn fieldON51,
      JoinOperator sqlOperator5,
      ITdoColumn fieldON52)
    {
      this.Initialize(5);

      this.joins[0] = join1;
      this.fields[0] = fieldON11; this.tables[0] = fieldON11.TdoEntity;
      this.sqlOperators[0] = sqlOperator1;
      this.fields[1] = fieldON12; this.tables[1] = fieldON12.TdoEntity;

      this.joins[1] = join2;
      this.fields[2] = fieldON21; this.tables[2] = fieldON21.TdoEntity;
      this.sqlOperators[1] = sqlOperator2;
      this.fields[3] = fieldON22; this.tables[3] = fieldON22.TdoEntity;

      this.joins[2] = join3;
      this.fields[4] = fieldON31; this.tables[4] = fieldON31.TdoEntity;
      this.sqlOperators[2] = sqlOperator3;
      this.fields[5] = fieldON32; this.tables[5] = fieldON32.TdoEntity;

      this.joins[3] = join4;
      this.fields[6] = fieldON41; this.tables[6] = fieldON41.TdoEntity;
      this.sqlOperators[3] = sqlOperator4;
      this.fields[7] = fieldON42; this.tables[7] = fieldON42.TdoEntity;

      this.joins[4] = join5;
      this.fields[8] = fieldON51; this.tables[8] = fieldON51.TdoEntity;
      this.sqlOperators[4] = sqlOperator5;
      this.fields[9] = fieldON52; this.tables[9] = fieldON52.TdoEntity;
    }

  }
  /// <summary>
  /// Sql Join Operators enumeration.
  /// </summary>
  [CLSCompliant(true)]
  [Serializable()]
  public enum JoinOperator
  {
    /// <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
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.