public static void Select(TkDbContext context, DataSet dataSet, string tableName, string sql) { using (SqlSelector selector = new SqlSelector(context, dataSet)) { selector.Select(tableName, sql); } }
public static void Select(TkDbContext context, DataSet dataSet, string tableName, string selectSql, IParamBuilder builder, string orderBy) { using (SqlSelector selector = new SqlSelector(context, dataSet)) { selector.Select(tableName, selectSql, builder, orderBy); } }
public static void Select(TkDbContext context, DataSet dataSet, string tableName, string sql, params IDbDataParameter[] dbParams) { using (SqlSelector selector = new SqlSelector(context, dataSet)) { selector.Select(tableName, sql, dbParams); } }
private DataTable CalTotalData(FilledListEventArgs e) { if (fStatFields.All(item => item.Method == StatMethod.Count)) { DataSet.Tables.Add(new DataTable("_Total")); } else { SqlSelector.Select(Context, DataSet, "_Total", CreateStatSql(), e.Condition); } DataTable table = DataSet.Tables["_Total"]; AppendCountPart(table, e.Count); return(table); }
public override OutputData DoAction(IInputData input) { using (SqlSelector selector = new SqlSelector(Context, DataSet)) { foreach (var item in fSqlList) { selector.Select(item.Item2, item.Item1); } } if (UseCallerInfo) { input.CallerInfo.AddInfo(DataSet); } string message = SuccessMessage ?? string.Empty; ActionResultData.CreateSuccessResult(message).AddToDataSet(DataSet); return(OutputData.Create(DataSet)); }
public void SelectTopRows(int topCount, IParamBuilder builder, string orderBy) { TkDebug.AssertArgumentNull(builder, "builder", this); TkDebug.AssertArgument(topCount > 0, "topCount", "参数必须大于0", this); string whereSql = builder.Sql; if (!string.IsNullOrEmpty(whereSql)) { whereSql = "WHERE " + whereSql; } var listContext = Context.ContextConfig.GetListSql(ListFields, Context.EscapeName(TableName), GetKeyFieldArray(), whereSql, orderBy, 0, topCount); SqlSelector selector = new SqlSelector(Context, HostDataSet); using (selector) { ISimpleAdapter adapter = selector; adapter.SetSql(listContext.ListSql, builder); Context.ContextConfig.SetListData(listContext, adapter, HostDataSet, 0, topCount, TableName); } }
public void Execute(SqlSelector selector) { InternalExecute(selector); }
protected void FillListDataSet(IInputData input, int pageNumber, int pageSize, int start) { ParamBuilderContainer condition = CreateListCondition(input); IOperateRight operateRight = null; if (TabSheets != null && TabSheets.Count > 0) { var selectedTab = GetSelectTabSheet(input); selectedTab.Selected = true; condition.Add(selectedTab.ParamBuilder); DataSet.Tables.Add(TabSheets.CreateTable("TabSheet")); } if (input.QueryString["GetData"] != "Page" && !input.IsPost) { MainResolver.FillCodeTable(input.Style); CreateListOperators(input, ref operateRight); } ListSortInfo listInfo = new ListSortInfo(input); string orderby = null; if (input.IsPost) { orderby = SetPostListInfo(input, condition, listInfo); } else { orderby = SetGetListInfo(input, condition, listInfo); } CountInfo pageInfo = CreatePageInfo(input, pageNumber, pageSize, condition); DataSet.Tables.Add(EnumUtil.Convert(pageInfo).CreateTable("Count")); DataSet.Tables.Add(EnumUtil.Convert(listInfo).CreateTable("Sort")); if (pageInfo.TotalCount <= 0) { OnFilledListTables(new FilledListEventArgs(input.IsPost, pageNumber, pageSize, pageInfo.TotalCount, orderby, MainResolver, input.PostObject, condition)); return; } int recCount = pageSize * pageNumber + start; string whereSql = condition.IsEmpty ? string.Empty : "WHERE " + condition.Sql; var listContext = FillListTable(MainResolver.ListFields, GetTableName(Context), MainResolver.GetKeyFieldArray(), whereSql, orderby, recCount, pageSize); SqlSelector selector = new SqlSelector(Context, DataSet); using (selector) { ISimpleAdapter adapter = selector; adapter.SetSql(listContext.ListSql, condition); Context.ContextConfig.SetListData(listContext, adapter, DataSet, recCount, pageSize, FillTableName); MainResolver.AddVirtualFields(); if (Operators != null) { if (operateRight == null) { operateRight = Operators.Right.CreateObject(); } var allOperators = Operators.Operators; if (allOperators != null) { CreateRowOperators(input, operateRight, allOperators); } } MainResolver.Decode(input.Style); OnFilledListTables(new FilledListEventArgs(input.IsPost, pageNumber, pageSize, pageInfo.TotalCount, orderby, MainResolver, input.PostObject, condition)); } }