示例#1
0
        public void WhenOneStatement_ThenReturnString()
        {
            var filter = Filter.When("Name", QueryComparison.Equal, "John").Build();

            var result = FilterConverter.ToTableQueryFilter(filter);

            Assert.That(result, Is.EqualTo("Name eq 'John'"));
        }
        /// <summary>
        /// Query the table using a filter.
        /// </summary>
        /// <param name="filter">Filter to apply in the query.</param>
        /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
        /// <returns>The task object representing the asynchronous operation. Result will contain list of matching entities.</returns>
        /// <exception cref="T:System.ArgumentNullException"><paramref name="filter" /> is null.</exception>
        public Task <IList <TEntity> > QueryAsync(Filter filter, CancellationToken cancellationToken = default)
        {
            if (filter == null)
            {
                throw new ArgumentNullException(nameof(filter));
            }

            var filterString = FilterConverter.ToTableQueryFilter(filter);

            return(_table.QueryAsync <TEntity>(filterString, cancellationToken));
        }
示例#3
0
        public void WhenTwoStatementsWithOrOp_ThenReturnString()
        {
            var filter = Filter
                         .When("Name", QueryComparison.Equal, "John")
                         .Or()
                         .When("Age", QueryComparison.Equal, "50")
                         .Build();

            var result = FilterConverter.ToTableQueryFilter(filter);

            Assert.That(result, Is.EqualTo("(Name eq 'John') or (Age eq '50')"));
        }
示例#4
0
        public void WhenTwoStatementsWithAndTwoOps_ThenReturnString()
        {
            var filter = Filter
                         .When("Name", QueryComparison.Equal, "John")
                         .And()
                         .When("Age", QueryComparison.Equal, "50")
                         .And()
                         .When("Address", QueryComparison.NotEqual, "Malaysia")
                         .Build();

            var result = FilterConverter.ToTableQueryFilter(filter);

            Assert.That(result, Is.EqualTo("((Name eq 'John') and (Age eq '50')) and (Address ne 'Malaysia')"));
        }
示例#5
0
        public void WhenIsNull_ThenReturnEmpty()
        {
            var result = FilterConverter.ToTableQueryFilter(null);

            Assert.That(result, Is.Empty);
        }