/// <summary> /// LeftJoin关键字项 /// </summary> /// <param name="prmsHandle">字段集合</param> /// <param name="previous">上一个关键字</param> internal KeyWordJoinItem(BQLTableHandle joinTable, BQLCondition condition, string keyWord, BQLQuery previous) : base(new BQLTableHandle[] { joinTable }, previous) { //this.joinTable = joinTable; this._condition = condition; this._keyWord = keyWord; }
/// <summary> /// 获取要显示的字段 /// </summary> /// <param name="handle"></param> /// <param name="propertys"></param> /// <returns></returns> private List <BQLParamHandle> GetParam(BQLTableHandle handle, ScopeList lstScope) { List <BQLParamHandle> lstParams = lstScope.GetShowProperty(handle); return(lstParams); }
/// <summary> /// 获取排序 /// </summary> /// <param name="lstScort"></param> /// <param name="table"></param> /// <param name="entityType"></param> /// <returns></returns> protected BQLParamHandle[] GetSort(SortList lstScort, BQLTableHandle table, Type entityType) { EntityInfoHandle entityInfo = null; if (entityType != null) { entityInfo = EntityInfoManager.GetEntityHandle(entityType); } return(BQLConditionScope.GetSort(lstScort, table, entityInfo)); }
/// <summary> /// 填充信息 /// </summary> /// <param name="condition"></param> /// <param name="table"></param> /// <param name="lstScope"></param> /// <param name="entityType"></param> public BQLCondition FillCondition(BQLCondition condition, BQLTableHandle table, ScopeList lstScope, Type entityType) { BQLCondition ret; EntityInfoHandle entityInfo = null; if (entityType != null) { entityInfo = EntityInfoManager.GetEntityHandle(entityType); } ret = BQLConditionScope.FillCondition(condition, table, lstScope, entityInfo); return(ret); }
/// <summary> /// from关键字 /// </summary> /// <param name="handle"></param> /// <returns></returns> internal override void Tran(KeyWordInfomation info) { StringBuilder ret = new StringBuilder(); if (info.AliasManager == null) { for (int i = 0; i < _tables.Length; i++) { BQLTableHandle table = _tables[i]; string tableName = table.DisplayValue(info); ret.Append(tableName); if (i < _tables.Length - 1) { ret.Append(","); } } info.Condition.Tables.Append(ret.ToString()); } else { for (int i = 0; i < _tables.Length; i++) { BQLTableHandle table = _tables[i]; BQLAliasHandle ahandle = info.AliasManager.GetPrimaryAliasHandle(table); if (!Buffalo.Kernel.CommonMethods.IsNull(ahandle)) { _tables[i] = ahandle; } } KeyWordFromItem from = info.AliasManager.ToInnerTable(this, info); TableAliasNameManager manager = info.AliasManager; info.AliasManager = null; Stack <KeyWordFromItem> stkFrom = new Stack <KeyWordFromItem>(); while (from != null) { stkFrom.Push(from); from = from.Previous as KeyWordFromItem; } while (stkFrom.Count > 0) { from = stkFrom.Pop(); from.Tran(info); } info.AliasManager = manager; } }
/// <summary> /// 获取主表的别名信息 /// </summary> /// <param name="table"></param> /// <returns></returns> public BQLAliasHandle GetPrimaryAliasHandle(BQLTableHandle table) { BQLEntityTableHandle eHandle = table as BQLEntityTableHandle; if (Buffalo.Kernel.CommonMethods.IsNull(eHandle)) { return(null); } if (eHandle.GetEntityInfo() == _primaryTable.EntityInfo) { return(_primaryTable.TableInfo); } return(null); }
/// <summary> /// 获取真正要显示的属性集合 /// </summary> /// <param name="handle"></param> /// <returns></returns> public List <BQLParamHandle> GetShowProperty(BQLTableHandle table) { List <BQLParamHandle> propertys = new List <BQLParamHandle>(); if (_showProperty != null && _showProperty.Count > 0) { foreach (BQLParamHandle param in _showProperty) { propertys.Add(param); } return(propertys); } BQLEntityTableHandle eTable = table as BQLEntityTableHandle; if (!CommonMethods.IsNull(eTable)) { foreach (EntityPropertyInfo info in eTable.GetEntityInfo().PropertyInfo) { string name = info.PropertyName; bool hidden = false; foreach (BQLParamHandle param in _hideProperty) { BQLEntityParamHandle eph = param as BQLEntityParamHandle; if (!CommonMethods.IsNull(eph)) { if (eph.PInfo.PropertyName == name) { hidden = true; break; } } } if (!hidden) { propertys.Add(eTable[info.PropertyName]); } } return(propertys); } if (!CommonMethods.IsNull(table)) { propertys.Add(table._); } return(propertys); }
/// <summary> /// 获取排序列表 /// </summary> /// <param name="lstScort"></param> /// <param name="table"></param> /// <param name="entityType"></param> /// <returns></returns> internal static BQLParamHandle[] GetSort(SortList lstScort, BQLTableHandle table, EntityInfoHandle entityInfo) { List <BQLParamHandle> lstHandles = new List <BQLParamHandle>(); if (lstScort == null) { lstHandles.ToArray(); } for (int i = 0; i < lstScort.Count; i++) { Sort objSort = lstScort[i]; BQLParamHandle handle = null; if (!CommonMethods.IsNull(objSort.OrderHandle)) { handle = objSort.OrderHandle; } else if (entityInfo != null) { //EntityPropertyInfo info = entityInfo.PropertyInfo[objSort.PropertyName]; if (objSort.SortType == SortType.ASC) { handle = table[objSort.PropertyName].ASC; } else { handle = table[objSort.PropertyName].DESC; } } else { if (objSort.SortType == SortType.ASC) { handle = table[objSort.PropertyName].ASC; } else { handle = table[objSort.PropertyName].DESC; } } lstHandles.Add(handle); } return(lstHandles.ToArray()); }
/// <summary> /// 填充查询条件并返回条件的SQL语句( and 开头) /// </summary> /// <param name="lstParam">参数列表</param> /// <param name="lstScope">范围查询集合</param> /// <returns></returns> internal static BQLCondition FillCondition(BQLCondition condition, BQLTableHandle table, ScopeList lstScope, EntityInfoHandle entityInfo) { BQLCondition ret = condition; if (lstScope == null) { return(ret); } BQLCondition curHandle = null; for (int i = 0; i < lstScope.Count; i++) { Scope objScope = lstScope[i]; EntityPropertyInfo info = null; if (entityInfo != null) { if (objScope.ScopeType == ScopeType.Condition) { curHandle = objScope.Value1 as BQLCondition; } else { //info = entityInfo.PropertyInfo[objScope.PropertyName]; curHandle = FormatScorp(objScope, DbType.Object, objScope.PropertyName, ret, table, entityInfo); } } else { curHandle = FormatScorp(objScope, DbType.Object, objScope.PropertyName, ret, table, entityInfo); } if (!Buffalo.Kernel.CommonMethods.IsNull(curHandle)) { if (objScope.ConnectType == ConnectType.And) { ret = ret & curHandle; } else { ret = ret | curHandle; } } } return(ret); }
///// <summary> ///// 要查询的字段 ///// </summary> //internal BQLTableHandle[] Tables //{ // get // { // return tables; // } //} /// <summary> /// 左连接 /// </summary> /// <param name="jionTable">表</param> /// <param name="on">条件</param> /// <returns></returns> public KeyWordJoinItem LeftJoin(BQLTableHandle joinTable, BQLCondition on) { KeyWordJoinItem item = new KeyWordJoinItem(joinTable, on, "left", this); return(item); }
/// <summary> /// 右外连接 /// </summary> /// <param name="jionTable">表</param> /// <param name="on">条件</param> /// <returns></returns> public KeyWordJoinItem RightOuterJoin(BQLTableHandle joinTable, BQLCondition on) { KeyWordJoinItem item = new KeyWordJoinItem(joinTable, on, "right outer", this); return(item); }
/// <summary> /// Update关键字项 /// </summary> /// <param name="table">表</param> /// <param name="previous">上一个关键字</param> public KeyWordUpdateItem(BQLTableHandle table, BQLQuery previous) : base(previous) { this.table = table; }
/// <summary> /// 内连接 /// </summary> /// <param name="jionTable">表</param> /// <param name="on">条件</param> /// <returns></returns> public KeyWordJoinItem InnerJoin(BQLTableHandle joinTable, BQLCondition on) { KeyWordJoinItem item = new KeyWordJoinItem(joinTable, on, "inner", this); return(item); }
/// <summary> /// 解释Between /// </summary> /// <param name="scope"></param> /// <param name="dbType"></param> /// <param name="paramName"></param> /// <param name="handle"></param> /// <param name="table"></param> /// <param name="entityInfo"></param> /// <returns></returns> internal static BQLCondition Between(Scope scope, DbType dbType, string paramName, BQLCondition handle, BQLTableHandle table, EntityInfoHandle entityInfo) { BQLValueTypeItem cvalue1 = new BQLValueTypeItem(scope.Value1); BQLValueTypeItem cvalue2 = null; if (scope.Value2 != null) { cvalue2 = new BQLValueTypeItem(scope.Value2); } return(table[paramName, dbType].Between(cvalue1, cvalue2)); }
/// <summary> /// 解释Condition /// </summary> /// <param name="scope"></param> /// <param name="dbType"></param> /// <param name="paramName"></param> /// <param name="handle"></param> /// <param name="table"></param> /// <param name="entityInfo"></param> /// <returns></returns> internal static BQLCondition Condition(Scope scope, DbType dbType, string paramName, BQLCondition handle, BQLTableHandle table, EntityInfoHandle entityInfo) { BQLCondition fhandle = scope.Value1 as BQLCondition; return(fhandle); }
/// <summary> /// 插入数据 /// </summary> /// <param name="arg">要被插入的表</param> /// <returns></returns> public static KeyWordInserItem InsertInto(BQLTableHandle arg) { KeyWordInserItem item = new KeyWordInserItem(arg, null); return(item); }
/// <summary> /// 删除数据 /// </summary> /// <param name="arg">要被删除数据的表</param> /// <returns></returns> public static KeyWordDeleteItem DeleteFrom(BQLTableHandle arg) { KeyWordDeleteItem item = new KeyWordDeleteItem(arg, null); return(item); }
/// <summary> /// 更新数据 /// </summary> /// <param name="arg">要被更新的表</param> /// <returns></returns> public static KeyWordUpdateItem Update(BQLTableHandle arg) { KeyWordUpdateItem item = new KeyWordUpdateItem(arg, null); return(item); }
/// <summary> /// 解释NotEqual /// </summary> /// <param name="scope"></param> /// <param name="dbType"></param> /// <param name="paramName"></param> /// <param name="handle"></param> /// <param name="table"></param> /// <param name="entityInfo"></param> /// <returns></returns> internal static BQLCondition NotEqual(Scope scope, DbType dbType, string paramName, BQLCondition handle, BQLTableHandle table, EntityInfoHandle entityInfo) { BQLValueTypeItem cvalue1 = new BQLValueTypeItem(scope.Value1); return(table[paramName, dbType] != cvalue1); }
/// <summary> /// Insert关键字项 /// </summary> /// <param name="tableHandle">要插入的表</param> /// <param name="previous">上一个关键字</param> internal KeyWordInserItem(BQLTableHandle tableHandle, BQLQuery previous) : base(previous) { this.tableHandle = tableHandle; }
/// <summary> /// 解释Scope /// </summary> /// <param name="scope"></param> /// <param name="dbType"></param> /// <param name="paramName"></param> /// <param name="handle"></param> /// <param name="table"></param> /// <param name="entityInfo"></param> /// <returns></returns> internal static BQLCondition DoScope(Scope scope, DbType dbType, string paramName, BQLCondition handle, BQLTableHandle table, EntityInfoHandle entityInfo) { ScopeList lstInnerScope = scope.Value1 as ScopeList; handle = BQLConditionScope.FillCondition(handle, table, lstInnerScope, entityInfo); return(handle); }
private static BQLCondition FormatScorp(Scope scope, DbType dbType, string pro, BQLCondition handle, BQLTableHandle table, EntityInfoHandle entityInfo) { ScopeType ctype = scope.ScopeType; BQLScopeExplainer delFun = BQLExplainScope.GetExplainer(scope); if (delFun != null) { //if (dbType == DbType.Object && scope.Value1 != null) //{ // dbType = DefaultType.ToDbType(scope.Value1.GetType()); //} handle = delFun(scope, dbType, pro, handle, table, entityInfo); } return(handle); }
/// <summary> /// 解释IN /// </summary> /// <param name="scope"></param> /// <param name="dbType"></param> /// <param name="paramName"></param> /// <param name="handle"></param> /// <param name="table"></param> /// <param name="entityInfo"></param> /// <returns></returns> internal static BQLCondition IN(Scope scope, DbType dbType, string paramName, BQLCondition handle, BQLTableHandle table, EntityInfoHandle entityInfo) { BQLValueTypeItem cvalue1 = new BQLValueTypeItem(scope.Value1); return(table[paramName, dbType].In(scope.Value1 as IEnumerable)); }
/// <summary> /// 交叉连接 /// </summary> /// <param name="jionTable">表</param> /// <param name="on">条件</param> /// <returns></returns> public KeyWordJoinItem CrossJoin(BQLTableHandle joinTable, BQLCondition on) { KeyWordJoinItem item = new KeyWordJoinItem(joinTable, on, "cross", this); return(item); }