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>();
精彩评论