May be used

Source: Internet
Author: User

Using system;
Using system. Collections. Generic;
Using system. LINQ;
Using system. text;
Using system. Text. regularexpressions;

Namespace consoleapplication21
{
Public interface ifiltergroupsql
{
String setgroupjoinsql (string SQL );
}

Public class countpartyunion: ifiltergroupsql
{
Public String setgroupjoinsql (string SQL)
{
SQL + = "countpartyunionsql union ";
Return SQL;
}
}

Public class businessunitunion: ifiltergroupsql
{
Public String setgroupjoinsql (string SQL)
{
SQL + = "businessunitsql union ";
Return SQL;
}
}
Public class businessunitunion1: ifiltergroupsql
{
Public String setgroupjoinsql (string SQL)
{
SQL + = "businessunitsql1 union ";
Return SQL;
}
}
Public class traderunion: ifiltergroupsql
{
Public String setgroupjoinsql (string SQL)
{

SQL + = "traderunionsql union ";
Return SQL;
}
}
Public class traderunion1: ifiltergroupsql
{
Public String setgroupjoinsql (string SQL)
{

SQL + = "traderunionsql1 union ";
Return SQL;
}
}

Public class filtergroupchain
{
Public ilist <ifiltergroupsql> filterchains = new list <ifiltergroupsql> ();

Public filtergroupchain addfiltergroupchain (ifiltergroupsql filter)
{
Filterchains. Add (filter );
Return this;
}

Public String setgroupjoinsql ()
{
String S = string. empty;
List <string> strlist = new list <string> ();

Foreach (var f in filterchains)
{
S = f. setgroupjoinsql (s );
}
S = RegEx. Replace (S, @ "(\ W *) (Union \ s) $", replacemethod );
Return S;
}

Private string replacemethod (match)
{
String S = "";

S = match. Groups [1]. tostring ();

Return S;
}
}
;
Class Program
{
Static void main (string [] ARGs)
{

Filtergroupchain = new filtergroupchain ();

Filtergroupchain. addfiltergroupchain (New countpartyunion ())
. Addfiltergroupchain (New businessunitunion ())
. Addfiltergroupchain (New traderunion ())
. Addfiltergroupchain (New traderunion1 ())
. Addfiltergroupchain (New businessunitunion1 ());
String S = filtergroupchain. setgroupjoinsql ();
Console. writeline (s );

Console. Read ();
}
}
}

May be used

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.