分享自己做的一个简单的查询表达式模拟(ESQL,Linq)(2)
2012-02-11 08:31
393 查看
下面是几个特殊化的表达式类:
4)常量表达式:
5)实体表信息表达式:
6)实体字段信息表达式:
7)别名表达式
4)常量表达式:
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)实体表信息表达式:
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)实体字段信息表达式:
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)别名表达式
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; } } }
相关文章推荐
- 分享自己做的一个简单的查询表达式模拟(ESQL,Linq)(1)
- 分享自己做的一个简单的查询表达式模拟(ESQL,Linq)(1)
- 分享自己做的一个简单的查询表达式模拟(ESQL,Linq)(2)
- 分享自己做的一个简单的查询表达式模拟(ESQL,Linq)(3)
- 分享自己做的一个简单的查询表达式模拟(ESQL,Linq)(3)
- 无奈自己写了一个简单的JDBC查询缓存,分享一下
- 分享一个小巧简单的基金查询工具(自己写的)
- 【C#】对异步请求处理程序IHttpAsyncHandler的理解和分享一个易用性封装 【手记】走近科学之为什么明明实现了IEnumerable<T>的类型却不能调用LINQ扩展方法 【手记】手机网页弹出层后屏蔽底层的滑动响应 【手记】ASP.NET提示“未能创建类型”处理 【Web】一个非常简单的移动web消息框 【手记】解决EXCEL跑SQL遇“查询无法运行或数据库表无法打开...”
- 分享一个小巧简单的基金查询工具(自己写的)
- 基于Linq表达式做的一个简单的表达式生成器
- 一个linq+lambda 表达式 分页查询的例子(查询 一段时间内所有用户登陆的次数)
- 自己模拟的一个简单的tomcat
- 自己模拟的一个简单的tomcat
- 找出超链接(无重复链接)-------自己有点小用,就简单写了一个,以后方便用,大家分享!
- 自己动手写一个简单正则表达式解析器(待续,未完成)
- 分享一个简单的资源管理器程序,主要是演示下LINQ在C#开发中的运用
- 分享 原创的一个模拟鼠标键盘操作的 设置简单 示例可以模拟向QQ群,以及QQ群内成员发送信息。
- Java中使用正则表达式的一个简单例子及常用正则分享
- 自己动手模拟开发一个简单的Web服务器
- 最近在写导出excel表格的代码,发现网上大部分代码都是导出简单格式的excel,所以自己顺便就写了一个导出复杂表格的工具类,有些代码是借鉴网友的,同时也谢谢分享代码的朋友们.