ApplyTo() 공개 메소드

Applies the predicate defined in this predicate builder to the result of SqlBuilder.Select().From().
thrown if selectFrom is null.
public ApplyTo ( IWhereOrOrderBy selectFrom ) : IAndOrOrderBy
selectFrom IWhereOrOrderBy The result of the select from method call.
리턴 IAndOrOrderBy
        public void ApplyToThrowsArgumentNullExceptionForNullSqlBuilder()
        {
            var rawWhereBuilder = new RawWhereBuilder();

            var exception = Assert.Throws<ArgumentNullException>(() => rawWhereBuilder.ApplyTo(null));

            Assert.Equal("selectFrom", exception.ParamName);
        }
        public void ApplyToEnsuresParametersAreRenumberedAndAllArgumentsAreAppended()
        {
            var rawWhereBuilder = new RawWhereBuilder();
            rawWhereBuilder.Append("ForeName = @p0 AND Surname = @p1", "Fred", "Flintstone")
                .Append(" AND Created > @p0", DateTime.Today)
                .Append(" AND LastLogin IS NOT NULL");

            var mockSqlBuilder = new Mock<IWhereOrOrderBy>();

            rawWhereBuilder.ApplyTo(mockSqlBuilder.Object);

            mockSqlBuilder.Verify(
                x => x.Where("ForeName = @p0 AND Surname = @p1 AND Created > @p2 AND LastLogin IS NOT NULL", "Fred", "Flintstone", DateTime.Today),
                Times.Once());
        }