Example #1
0
        private string TranslateIClause(IClause clause, DbCommand oCmd, ref int k)
        {
            String cmdText = "";

            if (clause is SingleClause)
            {
                SingleClause sc = clause as SingleClause;

                if (sc.Operator == CriteriaOperator.IsNull || sc.Operator == CriteriaOperator.IsNotNull)
                {
                    cmdText += String.Format("({0} {1})", sc.PropertyName, DaoSQLServerDBHelper.TranslateOperator(sc.Operator));
                }
                else
                {
                    string par = String.Format("p{0}", k++);
                    cmdText += String.Format("({0} {1} :{2})", sc.PropertyName, DaoSQLServerDBHelper.TranslateOperator(sc.Operator), par);
                    try
                    {
                        ObjectParameter p = new ObjectParameter(par, ((SingleClause)clause).Value.ToString());
                        //oCmd.Parameters.Add(par, ((SingleClause)clause).Value.ToString());
                    }
                    catch
                    {
                    }
                }
            }
            else if (clause is CombinedClause)
            {
                cmdText += "(";
                CombinedClause cc = clause as CombinedClause;
                for (int j = 0; j < cc.SubClauses.Count() - 1; j++)
                {
                    cmdText += String.Format("{0} {1} ", TranslateIClause(cc.SubClauses.ElementAt(j), oCmd, ref k),
                                             cc.ClauseType.ToString().ToUpper());
                }
                cmdText += String.Format("{0})", TranslateIClause(cc.SubClauses.Last(), oCmd, ref k));
            }
            return(cmdText);
        }