示例#1
0
        public void Should_Generate_Query_Expression_With_Null_Values()
        {
            var builder = new TableStorageQueryBuilder <PersonEntity>(new FilterExpression <PersonEntity>());

            builder.Query
            .Where("PartitionKey").Equal("Account-1")
            .And(p => p.AccountId).Equal(null)
            .And(p => p.ConsentDate).Equal(null);

            var queryStr = builder.Build();

            queryStr.Trim()
            .Should()
            .Be("PartitionKey eq 'Account-1' and AccountId eq '' and ConsentDate eq ''");
        }
示例#2
0
        public void Should_Build_Table_Storage_Advanced_Query_Expression()
        {
            var builder = new TableStorageQueryBuilder <PersonEntity>(new FilterExpression <PersonEntity>());

            builder.Query
            .Where("PartitionKey").Equal("Account-1")
            .And(p => p.AccountId).Equal("10")
            .And(p => p.Genre).Equal(Genre.Female);

            var queryStr = builder.Build();

            queryStr.Trim()
            .Should()
            .Be("PartitionKey eq 'Account-1' and AccountId eq '10' and Genre eq 'Female'");
        }
示例#3
0
        public void Should_Build_TableStorage_Query_Expression()
        {
            var builder = new TableStorageQueryBuilder <PersonEntity>(new FilterExpression <PersonEntity>());

            builder.Query
            .Where("PartitionKey").Equal("Account-1")
            .And(p => p.AccountId).Equal("10")
            .And(p => p
                 .Where(p => p.Created).GreaterThan(DateTimeOffset.Parse("2012-04-21T18:25:43Z"))
                 .Or(p => p.Created).LessThan(DateTimeOffset.Parse("2012-04-21T18:25:43Z")))
            .Not(p => p.Enabled).Equal(true);

            var queryStr = builder.Build();

            queryStr.Trim()
            .Should()
            .Be("PartitionKey eq 'Account-1' and AccountId eq '10' and (Created gt datetime'2012-04-21T18:25:43.0000000Z' or Created lt datetime'2012-04-21T18:25:43.0000000Z') not Enabled eq true");
        }