protected override DataTable FetchRows(TkDbContext context, DataSet dataSet, IParamBuilder builder, int topCount) { SqlSelector selector = new SqlSelector(context, dataSet); using (selector) { IParamBuilder addBuilder = CreateAdditionCondition(context, fScheme); builder = ParamBuilder.CreateParamBuilder(builder, addBuilder); string whereSql; if (builder == null) { whereSql = string.Empty; } else { whereSql = "WHERE " + builder.Sql; } TableSchemeData schemeData = TableSchemeData.Create(context, fScheme); var result = context.ContextConfig.GetListSql(schemeData.SelectFields, GetTableName(context), schemeData.KeyFieldArray, whereSql, OrderBy, 0, topCount); ISimpleAdapter adapter = selector; adapter.SetSql(result.ListSql, builder); context.ContextConfig.SetListData(result, adapter, dataSet, 0, TopCount, EASYSEARCH_TABLE_NAME); return(dataSet.Tables[EASYSEARCH_TABLE_NAME]); } }
protected override DataTable FillDbData(TkDbContext context, DataSet dataSet) { using (SqlSelector selector = new SqlSelector(context, dataSet)) { TableSchemeData data = new TableSchemeData(context, Scheme); ParamBuilderContainer container = new ParamBuilderContainer(); if (FilterSql != null) { string filter = Expression.Execute(FilterSql, selector); container.Add(filter); } container.Add(CreateActiveFilter(context)); string tableName = Scheme.TableName; string sql = string.Format(ObjectUtil.SysCulture, "SELECT {0} FROM {1}", data.SelectFields, context.EscapeName(tableName)); string regName = RegName; selector.Select(regName, sql, container, OrderBy); DataTable dataTable = dataSet.Tables[regName]; DataColumn idColumn = dataTable.Columns[fDisplay.Id.NickName]; idColumn.ColumnName = DecoderConst.CODE_NICK_NAME; dataTable.Columns[fDisplay.Name.NickName].ColumnName = DecoderConst.NAME_NICK_NAME; if (NameExpression != "{Name}") { foreach (DataRow row in dataTable.Rows) { row[DecoderConst.NAME_NICK_NAME] = InternalExpression.Execute(row); } } return(dataTable); } }
protected internal BaseSqlEasySearch(string sql, string idField, string nameField, TkDbContext context) : base(new SqlProxyScheme(DbUtil.CreateSqlTableScheme(sql, TABLE_NAME, idField, context), idField, nameField), StringUtil.GetNickName(idField), StringUtil.GetNickName(nameField), false) { fSql = sql; TableSchemeData schemeData = TableSchemeData.Create(context, ProxyScheme); fSelectFields = schemeData.SelectFields; }