Beispiel #1
0
        public void WhereNot()
        {
            var q = Builders <MyModel> .Select(x => new { x.Id })
                    .Where(x => !(x.Id == 1 && x.Name == "test"));

            var b = WhereBuilder <MyModel> .Not(WhereBuilder <MyModel> .And(
                                                    WhereBuilder <MyModel> .FromExpression(x => x.Id == 1),
                                                    WhereBuilder <MyModel> .Eq(x => x.Name, "test")));

            Utils.AssertRawQuery(q, b, @"SELECT ""id"" FROM model WHERE NOT(((""id"") = (1)) AND ((""name"") = ('test')))");
        }
Beispiel #2
0
        public void Column_WithNotCondition_AddsConditionToList()
        {
            var whereConditions = new List <WhereCondition>();
            var builder         = new WhereBuilder("table", whereConditions);

            builder.Not().Column("id", 1);

            whereConditions.Should()
            .ContainSingle()
            .Which.Should()
            .BeEquivalentTo(new CompareCondition("table", "id", "=", 1)
            {
                IsNot = true
            });
        }
Beispiel #3
0
        public void Grouped_WithNotCondition_AddsConditionToList()
        {
            var whereConditions = new List <WhereCondition>();
            var builder         = new WhereBuilder("table", whereConditions);

            builder.Not().Grouped(where => { });

            whereConditions.Should()
            .ContainSingle()
            .Which.Should()
            .BeEquivalentTo(new NestedCondition(new List <WhereCondition>())
            {
                IsNot = true
            });
        }