MicroLite.Builder.SelectSqlBuilder.Where C# (CSharp) Method

Where() public method

public Where ( string predicate ) : IAndOrOrderBy
predicate string
return IAndOrOrderBy
        public IAndOrOrderBy Where(string predicate, params object[] args)
        {
            if (string.IsNullOrEmpty(predicate))
            {
                throw new ArgumentException(ExceptionMessages.ArgumentNullOrEmpty.FormatWith("predicate"));
            }

            if (args != null)
            {
                for (int i = 0; i < args.Length; i++)
                {
                    this.Arguments.Add(new SqlArgument(args[i]));
                }
            }

            var renumberedPredicate = SqlUtility.RenumberParameters(predicate, this.Arguments.Count);

            this.InnerSql.Append(" WHERE (").Append(renumberedPredicate).Append(')');
            this.AddedWhere = true;

            return this;
        }

Same methods

SelectSqlBuilder::Where ( ) : IWhereExists
SelectSqlBuilder::Where ( string column ) : IWhereSingleColumn

Usage Example

        public void WhereThrowsArgumentExceptionForNullPredicate()
        {
            var sqlBuilder = new SelectSqlBuilder(SqlCharacters.Empty);

            var exception = Assert.Throws<ArgumentException>(
                () => sqlBuilder.Where(null, new object[0]));

            Assert.Equal(ExceptionMessages.ArgumentNullOrEmpty.FormatWith("predicate"), exception.Message);
        }
All Usage Examples Of MicroLite.Builder.SelectSqlBuilder::Where