public string[] AdicionarCondicaoEntre(string campo, object inicio, object fim)
        {
            var parametros      = new[] { string.Empty, string.Empty };
            var parametroInicio = string.Concat("_p", _proximoParametro.ToString(), "a");
            var parametroFim    = string.Concat("_p", _proximoParametro.ToString(), "b");

            if ((inicio != null) && (fim != null))
            {
                parametros[0] = parametroInicio;
                parametros[1] = parametroFim;
                Wheres.Add(string.Concat("([", campo, "]between @", parametroInicio, " and @", parametroFim, ")"));
            }
            else if (inicio != null)
            {
                parametros[0] = parametroInicio;
                Wheres.Add(string.Concat("([", campo, "]>=@", parametroInicio, ")"));
            }
            else
            {
                parametros[1] = parametroFim;
                Wheres.Add(string.Concat("([", campo, "]<=@", parametroFim, ")"));
            }

            _proximoParametro++;
            return(parametros);
        }
        public string[] AdicionarCondicaoEntre(string campo, object inicio, object fim)
        {
            var parametros      = new[] { string.Empty, string.Empty };
            var parametroInicio = "_p" + _proximoParametro.ToString() + "a";
            var parametroFim    = "_p" + _proximoParametro.ToString() + "b";

            if ((inicio != null) && (fim != null))
            {
                parametros[0] = parametroInicio;
                parametros[1] = parametroFim;
                Wheres.Add("([" + campo + "]between @" + parametroInicio + " and @" + parametroFim + ")");
            }
            else if (inicio != null)
            {
                parametros[0] = parametroInicio;
                Wheres.Add("([" + campo + "]>=@" + parametroInicio + ")");
            }
            else
            {
                parametros[1] = parametroFim;
                Wheres.Add("([" + campo + "]<=@" + parametroFim + ")");
            }

            _proximoParametro++;
            return(parametros);
        }
Beispiel #3
0
        /// <summary>
        /// Instancie o objeto e clona
        /// </summary>
        /// <param name="pTableQuery">Objeto table query</param>
        public TableQuery(TableQuery pTableQuery)
            : this()
        {
            DbName      = pTableQuery.DbName;
            TableName   = pTableQuery.TableName;
            FieldName   = pTableQuery.FieldName;
            Alias       = pTableQuery.Alias;
            SchemaTable = pTableQuery.SchemaTable;
            Top         = pTableQuery.Top;
            Distinct    = pTableQuery.Distinct;

            Fields = new TableAdapterFieldCollection(pTableQuery.Fields);

            foreach (OrderBy myItem in pTableQuery.OrderBy)
            {
                OrderBy.Add(new OrderBy(myItem));
            }

            pTableQuery.Wheres.ForEach(
                w => Wheres.Add(new WhereCollection(w)));

            if (pTableQuery.Joins != null)
            {
                pTableQuery.Joins.ForEach(
                    j => Joins.Add(new Join(j)));
            }

            if (pTableQuery.Union != eUnionType.eutNone)
            {
                pTableQuery.InternalQuery.ForEach(
                    c => InternalQuery.Add(new TableQuery(c)));
            }
        }
Beispiel #4
0
 /// <summary>
 /// Add a another condition to the WHERE Clause that need to be true
 /// </summary>
 /// <param name="where">The WHERE Clause to add</param>
 public virtual Where And(Where where)
 {
     if (where == null)
     {
         throw new System.ArgumentNullException();
     }
     Wheres.Add(where);
     return(this);
 }
Beispiel #5
0
 /// <summary>
 /// Add a another condition to the WHERE Clause that can be true instead
 /// </summary>
 /// <param name="where">The WHERE Clause to add</param>
 public virtual Where Or(Where where)
 {
     if (where == null)
     {
         throw new System.ArgumentNullException();
     }
     where.IsAnd = false;
     Wheres.Add(where);
     return(this);
 }
        public string AdicionarCondicao(string campo, int operador, object valor)
        {
            var parametro = "_p" + _proximoParametro.ToString();

            if ((valor == null) || (valor == DBNull.Value))
            {
                Wheres.Add("([" + campo + "]IS NULL)");
            }
            else
            {
                Wheres.Add("([" + campo + "]" + ConsultarSinalDoOperador(operador) + "@" + parametro + ")");
            }
            _proximoParametro++;
            return(parametro);
        }
Beispiel #7
0
 public SqlBuilderUpdate Where(string name, object value)
 {
     Wheres.Add(Provider.CreateTag(name), value);
     return(this);
 }
 public void AdicionarCondicaoApenasCampoNaoNulo(string campo)
 {
     Wheres.Add("([" + campo + "]IS NOT NULL)");
 }
 public void AdicionarCondicaoPersonalizada(string condicao)
 {
     Wheres.Add("(" + condicao + ")");
 }
 public void AdicionarCondicaoApenasCampoNaoNulo(string campo)
 {
     Wheres.Add(string.Concat("([", campo, "]IS NOT NULL)"));
 }
 public void AdicionarCondicaoPersonalizada(string condicao)
 {
     Wheres.Add(string.Concat("(", condicao, ")"));
 }
Beispiel #12
0
        /// <summary>
        /// Add a basic where clause with a custom operator to the query.
        /// </summary>
        /// <param name="column">The column to which the clause applies.</param>
        /// <param name="ope">The operator for the where clause.</param>
        /// <param name="value">The value of the clause.</param>
        /// <param name="boolean">The boolean that applies for the where clause.</param>
        /// <returns>The current query.</returns>
        public Builder <T> Where(string column, string ope, dynamic value, string boolean = "AND")
        {
            Wheres.Add(new WhereClause(column, ope, value, boolean));

            return(this);
        }