コード例 #1
0
        IParamBuilder ISearch.Search(EasySearch easySearch, SearchField searchType,
                                     TkDbContext context, IFieldInfo fieldName, string fieldValue)
        {
            TkDebug.AssertArgumentNull(context, "context", this);
            TkDebug.AssertArgumentNull(fieldName, "fieldName", this);

            if (string.IsNullOrEmpty(fieldValue))
            {
                return(null);
            }

            fieldValue = StringUtil.EscapeAposString(fieldValue);
            string sql;

            if (fieldValue.IndexOfAny(WideChars) != -1)
            {
                fieldValue = StringUtil.EscapeSqlString(fieldValue);
                sql        = string.Format(ObjectUtil.SysCulture,
                                           "(({0} LIKE '{1}%' ESCAPE '\\') OR ({0} LIKE '{2}%' ESCAPE '\\') OR ({3}))",
                                           context.EscapeName(fieldName.FieldName), fieldValue.ToUpper(ObjectUtil.SysCulture),
                                           fieldValue.ToLower(ObjectUtil.SysCulture),
                                           PinYinUtil.GetCharFullCondition(context, fieldName.FieldName, fieldValue));
            }
            else
            {
                sql = string.Format(ObjectUtil.SysCulture,
                                    "(({0} LIKE '{1}%') OR ({0} LIKE '{2}%') OR ({3}))",
                                    context.EscapeName(fieldName.FieldName), fieldValue.ToUpper(ObjectUtil.SysCulture),
                                    fieldValue.ToLower(ObjectUtil.SysCulture),
                                    PinYinUtil.GetCharFullCondition(context, fieldName.FieldName, fieldValue));
            }
            return(SqlParamBuilder.CreateSql(sql));
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        protected override IParamBuilder CreateActiveFilter(TkDbContext context)
        {
            string sql = string.Format(ObjectUtil.SysCulture, "{0} IS NULL OR {0} <> 1",
                                       context.EscapeName(DecoderConst.DEL_FIELD_NAME));

            return(SqlParamBuilder.CreateSql(sql));
        }
コード例 #4
0
        private IParamBuilder InternalCreateLikeSql(TkDbContext context, IFieldInfo fieldName,
                                                    string likeValue, string exceptValue)
        {
            string fieldName1 = fieldName.FieldName + "1";
            string fieldName2 = fieldName.FieldName + "2";

            fSql = string.Format(ObjectUtil.SysCulture, "{0} LIKE {1} AND {0} <> {2}",
                                 context.EscapeName(fieldName.FieldName), context.GetSqlParamName(fieldName1),
                                 context.GetSqlParamName(fieldName2));

            fParams.Add(fieldName1, fieldName.DataType, likeValue);
            fParams.Add(fieldName2, fieldName.DataType, exceptValue);

            return(this);
        }
コード例 #5
0
 protected virtual string GetTableName(TkDbContext context)
 {
     return(context.EscapeName(fScheme.TableName));
 }