分享自己做的一个简单的查询表达式模拟(ESQL,Linq)(2)
下面是几个特殊化的表达式类:
4)常量表达式:
[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)实体表信息表达式:
[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)实体字段信息表达式:
[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)别名表达式
[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");
补充:软件开发 , C# ,