/// <summary> /// 添加检索操作,不带过滤条件 /// </summary> /// <param name="sqlExpression"></param> /// <param name="fillDs"></param> public override void AddAction(string sqlExpression, DataSet fillDs, EnumDBReturnAccess enumReturn) { if (enumReturn == EnumDBReturnAccess.ExeNoQuery || enumReturn == EnumDBReturnAccess.SaveDS || enumReturn == EnumDBReturnAccess.Scalar) { ExtConsole.Write("该接口只提供填充数据集的功能!"); return; } Expression sql = this.createSqlAction(); sql.SqlBusiness = sqlExpression; sql.ReturnDS = fillDs; sql.EnumReturn = enumReturn; this._executor.Actions.Add(sql); }
/// <summary> /// /// </summary> /// <param name="sqlExpression"></param> /// <param name="enumReturn"></param> /// <param name="conditions"></param> public override void AddAction(string sqlExpression, EnumDBReturnAccess enumReturn, DBConditions conditions) { #region if (enumReturn == EnumDBReturnAccess.SaveDS || enumReturn == EnumDBReturnAccess.FillDsByCustom || enumReturn == EnumDBReturnAccess.FillDsByStoredProcedure) { ExtConsole.Write("该接口不提供存储数据集或检索数据集功能!"); return; } Expression sql = this.createSqlAction(); sql.SqlBusiness = sqlExpression; sql.EnumReturn = enumReturn; sql.SqlConditions = conditions; this._executor.Actions.Add(sql); #endregion }
/// <summary> /// /// </summary> /// <param name="expression"></param> /// <returns></returns> private static string getAllKeys(Expression expression) { #region string keys = ""; if (expression.SqlConditions != null) { List <string> dskeys = expression.SqlConditions.DataSetKeys; if (dskeys != null) { for (int i = 0; i < dskeys.Count; i++) { string temp = dskeys[i]; if (i == 0) { keys += temp; } else { keys += string.Format("+{0}", temp); } } } else { keys = getKeysByReturnDs(expression.ReturnDS); } } else { keys = getKeysByReturnDs(expression.ReturnDS); } if (keys == "") { ExtConsole.Write("系统提示:未指定关联键,sql语句构建出错!"); } return(keys); #endregion }
/// <summary> /// 获取数据表的表名和第一关键字的字段名 /// </summary> /// <param name="destDs"></param> /// <param name="tablename"></param> /// <param name="keyname"></param> protected void gettablekey(DataSet destDs, ref string tablename, ref string keyname) { #region if (destDs.Tables.Count > 0) { tablename = destDs.Tables[0].TableName; if (destDs.Tables[0].PrimaryKey.Length > 0) { keyname = destDs.Tables[0].PrimaryKey[0].ColumnName; } else { ExtConsole.Write("目标数据表中没有设定主键!"); } } else { ExtConsole.Write("传入的数据集没有DataTable!"); } #endregion }
/// <summary> /// /// </summary> /// <param name="willSaveDs"></param> /// <returns></returns> public String CreateBuilderSelect(DataSet willSaveDs) { #region DataTable willsavedt = willSaveDs.Tables[0]; string tablename = willsavedt.TableName; if (string.IsNullOrEmpty(tablename)) { ExtConsole.Write("欲保存的数据集表名为NULL或者为空值!"); } if (willsavedt.PrimaryKey.Length <= 0) { ExtConsole.Write("欲保存的数据集没有主键,不能自动生成sql语句!"); } string keyfieldname = willSaveDs.Tables[0].PrimaryKey[0].ColumnName; string sqlexpression = String.Format("select * from [{0}] where {1}='' ", tablename, keyfieldname); return(sqlexpression); #endregion }