这是我的代码:
TransactionCollection transactions = new TransactionCollection();
transactions.Where("next_action", "RESEND");
transactions.Where("job_id", CurrentJob.Id);
transactions.Load();
我真的希望它说next_action是RESEND或者next_action是TARGET。感谢。
基本上我想要一个像这样的选择状态:
select * from transactions where job_id = 1 and (next_action = 'RESEND' OR next_action = 'TARGET');
或
select * from transactions where job_id = 1 and next_action IN ('RESEND', 'TARGET');
答案 0 :(得分:2)
如果您使用的是SubSonic 2.1或更高版本,则可以利用AndExpression和OrExpression。对于您的第一个示例,以下内容应该有效:
TransactionCollection transactions = DB.Select().From(Transaction.Schema)
.Where("job_id", CurrentJob.Id);
.AndExpression("next_action")IsEqualTo("RESEND")
.Or("next_action")IsEqualTo("TARGET")
.ExecuteCollection<TransactionCollection>()