How to make or choose when using subsonic?

Here is my code:

TransactionCollection transactions = new TransactionCollection();
transactions.Where("next_action", "RESEND");
transactions.Where("job_id", CurrentJob.Id);
transactions.Load();

      

I really want to say that next_action is RESEND or next_action is TARGET. Thanks.

Basically I want to select statemnt like this:

select * from transactions where job_id = 1 and (next_action = 'RESEND' OR next_action = 'TARGET');

      

or

select * from transactions where job_id = 1 and next_action IN ('RESEND', 'TARGET');

      

0


a source to share


1 answer


If you are on SubSonic 2.1 or higher, you can use AndExpression and OrExpression. For your first example, the following should work:



TransactionCollection transactions = DB.Select().From(Transaction.Schema)
  .Where("job_id", CurrentJob.Id);
  .AndExpression("next_action")IsEqualTo("RESEND")
  .Or("next_action")IsEqualTo("TARGET")
  .ExecuteCollection<TransactionCollection>()

      

+2


a source







All Articles