private static void AddConditions(Select targetSelect, QueryCondition conditions) { if (targetSelect.Condition.Count > 0) { var originalConditions = new QueryCondition(targetSelect.Condition); targetSelect.Condition.Clear(); originalConditions.WrapBlock(); targetSelect.Condition.Add(originalConditions); targetSelect.Condition.Add(new QueryCondition { LogicalOperation = LogicalOperation.And }); targetSelect.Condition.Add(conditions); } else { targetSelect.Where(conditions); } }