using System;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Text;
namespace Ant.ORM
{
///
/// 在此描述QueryCondition的说明
///
[Serializable]
public class MakeQueryWhere
{
public Dictionary QueryList = new Dictionary();
private QueryWhereList ColumnList;
public MakeQueryWhere()
{
ColumnList = new QueryWhereList();
}
/////
///// 表名
/////
//public string TableName
//{
// get;
// set;
//}
///
/// 并且条件
///
///
///
public MakeQueryWhere And(Expression> expression,Operator op,object value) where T : class
{
//PropertyInfo propertyInfo = ReflectionHelper.GetProperty(expression) as PropertyInfo;
//TableColumn tc = new TableColumn();
//tc.ColumnMetaData = column.ColumnMetaData;
//tc.TableName = column.TableName;
//tc.Operatstr = column.Operatstr;
//if (ColumnList.QueryList.IsNull())
// ColumnList.QueryList = new List();
//foreach (QueryWhereList queryList in QueryList.Values)
//{
// var num = queryList.QueryList.Select(p => p.ColumnName.Equals(tc.ColumnName)).Count();
// if (num>0)
// {
// tc.OverColumnName = tc.ColumnName + num;
// }
//}
//ColumnList.QueryList.Add(tc);
//ColumnList.WhereStr = " and ";
return this;
}
///
/// 或者条件
///
///
///
public MakeQueryWhere Or(Expression> expression, Operator op, object value) where T : class
{
//TableColumn tc = new TableColumn();
//tc.ColumnMetaData = column.ColumnMetaData;
//tc.TableName = column.TableName;
//if (ColumnList.QueryList.IsNull())
// ColumnList.QueryList = new List();
//foreach (QueryWhereList queryList in QueryList.Values)
//{
// var num = queryList.QueryList.Select(p => p.ColumnName.Equals(tc.ColumnName)).Count();
// if (num > 0)
// {
// tc.OverColumnName = tc.ColumnName + num;
// }
//}
//ColumnList.QueryList.Add(tc);
//ColumnList.WhereStr = " or ";
return this;
}
///
/// 设置分组
///
public void SetGroup()
{
QueryList.Add(Guid.NewGuid().ToString(), ColumnList);
ColumnList = new QueryWhereList();
}
}
///
///
///
public class QueryWhereList
{
public List QueryList
{
get;
set;
}
///
/// 操作符
///
public string WhereStr
{
get;
set;
}
}
}