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