/// <summary> /// EndWith条件 /// </summary> /// <param name="item">条件</param> /// <returns></returns> public BQLConditionItem EndWith(object item) { BQLValueItem oValue = BQLValueItem.ToValueItem(item); oValue.ValueDbType = this.ValueDbType; return(new BQLConditionItem(this, new BQLValueItem[] { oValue }, BQLConditionManager.DoEndWith)); }
internal override void FillInfo(KeyWordInfomation info) { foreach (BQLValueItem value in parameters) { BQLValueItem.DoFillInfo(value, info); } }
/// <summary> /// 执行填充信息操作 /// </summary> /// <param name="value">要执行的值</param> /// <param name="info">信息</param> public static void DoFillInfo(BQLValueItem value, KeyWordInfomation info) { if (!CommonMethods.IsNull(value)) { value.FillInfo(info); } }
internal override void FillInfo(KeyWordInfomation info) { if (info.AliasManager != null) { BQLValueItem.DoFillInfo(_belongTable, info); } }
public BQLCaseHandle(BQLValueItem item) { this.caseItem = item; //this.valueType = BQLValueType.Case; //this.valueDataType = DefaultType.StringType; this._valueDbType = DbType.String; }
/// <summary> /// Between条件 /// </summary> /// <param name="star">开始值</param> /// <param name="end">结束值</param> /// <returns></returns> public BQLConditionItem Between(object star, object end) { BQLValueItem oValue1 = BQLValueItem.ToValueItem(star); BQLValueItem oValue2 = BQLValueItem.ToValueItem(end); oValue1.ValueDbType = this.ValueDbType; oValue2.ValueDbType = this.ValueDbType; return(new BQLConditionItem(this, new BQLValueItem[] { oValue1, oValue2 }, BQLConditionManager.DoBetween)); }
/// <summary> /// 进行除法运算 /// </summary> /// <param name="handle"></param> /// <returns></returns> internal static string DoMod(BQLOperatorHandle handle, KeyWordInfomation info) { BQLValueItem[] parameters = handle.GetParameters(); BQLValueItem item1 = parameters[0]; BQLValueItem item2 = parameters[1]; string value1 = item1.DisplayValue(info); string value2 = item2.DisplayValue(info); return(info.DBInfo.Math.DoMod(new string[] { value1, value2 })); }
/// <summary> /// 截取字符串 /// </summary> /// <param name="start">字符串起始位置</param> /// <param name="length">字符串长度</param> /// <returns></returns> public CsqCommonFunction SubString(BQLValueItem start, BQLValueItem length) { start.ValueDbType = DbType.Int32; length.ValueDbType = DbType.Int32; CsqCommonFunction handle = new CsqCommonFunction(new BQLValueItem[] { this, start, length }, DBMathFunction.SubString, DbType.Int32); //handle.ValueDataType = DefaultType.IntType; handle.ValueDbType = DbType.Int32; return(handle); }
/// <summary> /// 不等于 /// </summary> /// <param name="handle"></param> /// <returns></returns> internal static string DoNotequal(BQLComparItem handle, KeyWordInfomation info) { IList <BQLValueItem> parameters = handle.GetParameters(); if (parameters[1].IsNullValue()) { BQLValueItem item = parameters[0]; return(item.DisplayValue(info) + " is not null"); } return(ConditionsFunction(handle, "<>", info)); }
public static BQLComparItem operator <=(BQLValueItem handle, object value) { BQLValueItem oValue = ToValueItem(value); UnityDbType(handle, oValue); BQLComparItem fHandle = new BQLComparItem(FunctionManager.DoLessThen, new BQLValueItem[] { handle, oValue }); //fHandle.PriorityLevel = 5; fHandle.PriorityLevel = OperatorPrecedenceUnit.GetPrecedence("<="); return(fHandle); }
public static BQLOperatorHandle operator /(BQLValueItem handle, object value) { BQLValueItem oValue = ToValueItem(value); UnityDbType(handle, oValue); BQLOperatorHandle fHandle = new BQLOperatorHandle(FunctionManager.DoDiv, new BQLValueItem[] { handle, oValue }); //fHandle.PriorityLevel = 7; fHandle.PriorityLevel = OperatorPrecedenceUnit.GetPrecedence("/"); return(fHandle); }
/// <summary> /// 查找字符 /// </summary> /// <param name="value">要查找的字符</param> /// <param name="start">起始位置</param> /// <returns></returns> public CsqCommonFunction IndexOf(object value, BQLValueItem start) { BQLValueItem oValue = BQLValueItem.ToValueItem(value);; start.ValueDbType = DbType.Int32; if (oValue.ValueDbType == DbType.Object) { oValue = DbType.String; } CsqCommonFunction handle = new CsqCommonFunction(new BQLValueItem[] { oValue, this, start }, DBMathFunction.IndexOf, DbType.Int32); //handle.ValueDataType = DefaultType.IntType; handle.ValueDbType = DbType.Int32; return(handle); }
/// <summary> /// 把传进来的值转换成BQL能识别的值项 /// </summary> /// <param name="value"></param> /// <returns></returns> public static BQLValueItem ToValueItem(object value) { BQLQuery query = value as BQLQuery; if (!CommonMethods.IsNull(query)) { return(query.AS(null)); } BQLValueItem item = value as BQLValueItem; if (CommonMethods.IsNull(item)) { item = new BQLValueTypeItem(value); } return(item); }
/// <summary> /// 填充值的括号 /// </summary> /// <param name="left">连接符左边</param> /// <param name="isLeft">是否在运算符左边</param> /// <param name="operLevel">当前符号优先级</param> /// <param name="info">输出信息</param> /// <returns></returns> public static string FillBreak(BQLValueItem value, bool isLeft, int operLevel, KeyWordInfomation info) { IOperatorPriorityLevel pl = value as IOperatorPriorityLevel; if (pl == null) { return(value.DisplayValue(info)); } if ((!info.DBInfo.OperatorPrecedence) || (isLeft && pl.PriorityLevel < operLevel) || ((!isLeft) && pl.PriorityLevel <= operLevel) ) { return("(" + value.DisplayValue(info) + ")"); } return(value.DisplayValue(info)); }
/// <summary> /// 普通连接函数 /// </summary> /// <param name="handle">函数</param> /// <param name="connect">连接符</param> /// <param name="operLevel">优先级</param> /// <returns></returns> private static string CustomerConnectFunction(IList <BQLValueItem> parameters, string connect, KeyWordInfomation info, int operLevel) { //BQLValueItem[] parameters = fHandle.GetParameters(); string values = ""; for (int i = 0; i < parameters.Count; i++) { BQLValueItem item = parameters[i]; //values += item.DisplayValue(info); values += OperatorPrecedenceUnit.FillBreak(item, i == 0, operLevel, info); if (i < parameters.Count - 1) { values += connect; } } return(values); }
/// <summary> /// 进行加法运算 /// </summary> /// <param name="handle"></param> /// <returns></returns> internal static string DoAdd(BQLOperatorHandle fHandle, KeyWordInfomation info) { BQLValueItem[] parameters = fHandle.GetParameters(); BQLValueItem item1 = parameters[0]; BQLValueItem item2 = parameters[1]; if (IsStringDBType(item1.ValueDbType) || IsStringDBType(item2.ValueDbType)) //字符串拼合 { string value1 = item1.DisplayValue(info); string value2 = item2.DisplayValue(info); //if(OperatorPrecedenceUnit.LeftNeedBreak( fHandle.ValueDbType = DbType.String; return(info.DBInfo.CurrentDbAdapter.ConcatString(value1, value2)); } else { fHandle.ValueDbType = DbType.Double; } return(CustomerConnectFunction(fHandle.GetParameters(), "+", info, fHandle.PriorityLevel)); }
/// <summary> /// 统一数据库值类型 /// </summary> /// <param name="value1"></param> /// <param name="value2"></param> protected internal static void UnityDbType(BQLValueItem value1, BQLValueItem value2) { if (CommonMethods.IsNull(value1) || CommonMethods.IsNull(value2)) { return; } DbType type = DbType.Object; if (value1.ValueDbType != value2.ValueDbType) { if (value1.ValueDbType != DbType.Object) { value2.ShowDbType(value1.ValueDbType); } else if (value2.ValueDbType != DbType.Object) { value1.ShowDbType(value2.ValueDbType); } } //if (value1.ValueDbType != DbType.Object) //{ // type = value1.ValueDbType; //} //if (value2.ValueDbType != DbType.Object) //{ // type = value2.ValueDbType; //} //if (type != DbType.Object) //{ // if (value1.ValueDbType == DbType.Object) // { // value1.ValueDbType = type; // } // if (value2.ValueDbType == DbType.Object) // { // value2.ValueDbType = type; // } //} }
public BQLAliasParamHandle(BQLValueItem prmHandle, string aliasName) { this._prmHandle = prmHandle; this._aliasName = aliasName; }
internal override void FillInfo(KeyWordInfomation info) { //info.QueryParams[aliasName] = new ParamInfo(aliasName, aliasName, prmHandle.ValueDataType); BQLValueItem.DoFillInfo(_prmHandle, info); }
///// <summary> ///// CaseµÄÏî ///// </summary> //internal BQLKeyWordItem CaseItem //{ // get // { // return caseItem; // } //} internal override void FillInfo(KeyWordInfomation info) { BQLValueItem.DoFillInfo(caseItem, info); }