Share your own simple query expression simulation (ESQL, Linq) (2)

Source: Internet
Author: User

Below are several specialized expression classes:
4) constant expression:
[Csharp]
Public class ConstExp <T>: DbExpression
{
Public string ParamName {get; private set ;}
Public T Value {get; private set ;}
Public ConstExp (T Value, string ParamName)
: Base ()
{
This. Parameters. Add (ParamName, new Parameter (){});
This. Value = Value;
This. ParamName = ParamName;
}
Public override string Expression
{
Get
{
Return ":" + this. ParamName;
}
}
 
Public static ConstExp <T> C (string ParamName, t v)
{
Return new ConstExp <T> (V, ParamName );
}
}

5) object table information expression:
[Csharp]
Public class TableInfo: IDbExpression
{
Public string TableName {get; set ;}
Public string Expression
{
Get {return TableName ;}
}
 
Public virtual Dictionary <string, Parameter> Parameters {get {return null ;}}
}
6) object field information expression:
[Csharp]
Public class FieldInfo: IDbExpression
{
Public string FieldName {get; set ;}
Public string Expression
{
Get {return FieldName ;}
}
Public virtual Dictionary <string, Parameter> Parameters {get {return null ;}}
 
Public static FieldInfo All
{
Get
{
Return new FieldInfo () {FieldName = "*"};
}
}
}

7) alias expression
[Csharp]
Public class AliasExp: DbExpression
{
Public AliasExp (string AliasName)
{
This. AliasName = AliasName;
}
Public string AliasName {get; private set ;}
Public override string Expression
{
Get
{
Return "AliasName ";
}
}
Public override Dictionary <string, Parameter> Parameters
{
Get
{
Return null;
}
}
Public static readonly AliasExp T1;
Public static readonly AliasExp T2;
Public static readonly AliasExp T3;
Public static readonly AliasExp T4;
Public static readonly AliasExp T5;
Public static readonly AliasExp T6;
Public static readonly AliasExp T7;
Public static readonly AliasExp T8;
Public static readonly AliasExp T9;
Public static readonly AliasExp A1;
Public static readonly AliasExp A2;
Public static readonly AliasExp A3;
Public static readonly AliasExp A4;
Public static readonly AliasExp A5;
Public static readonly AliasExp A6;
Static AliasExp ()
{
T1 = new AliasExp ("T1 ");
T2 = new AliasExp ("T2 ");
T3 = new AliasExp ("T3 ");
T4 = new AliasExp ("T4 ");
T5 = new AliasExp ("T5 ");
T6 = new AliasExp ("T6 ");
T7 = new AliasExp ("T7 ");
T8 = new AliasExp ("T8 ");
T9 = new AliasExp ("T9 ");
A1 = new AliasExp ("A1 ");
A2 = new AliasExp ("A2 ");
A3 = new AliasExp ("A3 ");
A4 = new AliasExp ("A4 ");
A5 = new AliasExp ("A5 ");
A6 = new AliasExp ("A6 ");
}
Public DbExpression this [FieldInfo e]
{
Get
{
DbExpression theExp = new DbExpression ();
TheExp. SQL. Append (this. AliasName + "." + e. Expression );
TheExp. AddParams (e );
Return theExp;
}
}
Public DbExpression this [TableInfo e]
{
Get
{
DbExpression theExp = new DbExpression ();
TheExp. SQL. Append (e. Expression + "" + this. AliasName );
TheExp. AddParams (e );
Return theExp;
}
}
Public DbExpression this [DbExpression e]
{
Get
{
DbExpression theExp = new DbExpression ();
TheExp. SQL. Append (e. Expression + "" + this. AliasName );
TheExp. AddParams (e );
Return theExp;
}
}
}

From hawksoft

Related Article

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.