Ejemplo n.º 1
0
        private string CreateSearchCondition(ColumnDisplay disp, ISqlDialect dialect, IDmlfHandler handler)
        {
            if (disp == null)
            {
                disp = m_lastColumnDisplay;
            }
            if (disp == null)
            {
                return("1=1");
            }
            bool          was = false;
            StringBuilder res = new StringBuilder();
            //ITableStructure table = TableData.GetStructure(Perspective);
            var dda   = dialect.CreateDataAdapter();
            var spars = new FulltextSearchParams {
                ExactMatch = SearchExactMatch
            };

            foreach (var col in disp)
            {
                var cs = (IColumnStructure)col.ValueTag;
                if (cs == null)
                {
                    continue;
                }
                if (cs.DataType is DbTypeXml || cs.DataType is DbTypeBlob)
                {
                    continue;
                }
                if (SearchColumns != null && Array.IndexOf(SearchColumns, col.ValueRef.ToString()) < 0)
                {
                    continue;
                }
                if (was)
                {
                    res.Append(" OR ");
                }
                res.Append(dda.GetFulltextSearchExpr(col.ValueRef.Expr.ToSql(dialect, handler), SearchText, spars));
                //res.AppendFormat("{0} LIKE {1}", dialect.QuoteIdentifier(col.ColumnName), dialect.GetSqlLiteral("%" + SearchText + "%"));
                was = true;
            }
            if (!was)
            {
                res.Append("1=1");
            }
            return("(" + res.ToString() + ")");
        }
Ejemplo n.º 2
0
 public virtual string GetFulltextSearchExpr(string expr, string substring, FulltextSearchParams pars)
 {
     substring = substring.Replace("@", "@@").Replace("%", "@%").Replace("_", "@_");
     return(String.Format("({0} LIKE {1} ESCAPE '@')", expr, this.GetSqlLiteral(pars.LikePrefix + substring + pars.LikePostfix)));
 }