开发者

SubSonic OpenExpression/CloseExpression

开发者 https://www.devze.com 2022-12-11 04:21 出处:网络
Hey All! I\'m trying to construct a query that is something like this: Where column = \"value\" AND column2 = \"value\" AND (column3 = \"value\" OR column4 = \"value\")

Hey All! I'm trying to construct a query that is something like this:

Where column = "value" AND column2 = "value" AND (column3 = "value" OR column4 = "value")

I have this code:

return new Select()
               .From(LessonChallenge.Schema)
               .Where(LessonChallenge.ChallengerStatusColumn).IsEqualTo("Finished")
               .And(LessonChallenge.ChallengeeStatusColumn).IsEqualTo("Finished")
               .OpenExpression()
                    .And(LessonChallenge.ChallengerAccountIDColumn).IsEqualTo(accountID)
                    .Or(LessonChallenge.ChallengeeAccountIDColumn).IsEqualTo(accountID)
               .CloseExpression()
               .OrderDesc("dateCompleted")
               .Page开发者_如何学God(1, numItems)
               .ExecuteAsCollection<LessonChallengeCollection>();

Problem is that SubSonic is adding the And after the parenthesis. How can I negate that?


You should be able to do:

return new Select()
           .From(LessonChallenge.Schema)
           .Where(LessonChallenge.ChallengerStatusColumn).IsEqualTo("Finished")
           .And(LessonChallenge.ChallengeeStatusColumn).IsEqualTo("Finished")
           .AndExpression(LessonChallenge.ChallengerAccountIDColumn).IsEqualTo(accountID)
                .Or(LessonChallenge.ChallengeeAccountIDColumn).IsEqualTo(accountID)
           .OrderDesc("dateCompleted")
           .Paged(1, numItems)
           .ExecuteAsCollection<LessonChallengeCollection>();
0

精彩评论

暂无评论...
验证码 换一张
取 消