public static int DeleteFrom(this IQuery context, ObjectName tableName, SqlQueryExpression query, int limit)
        {
            IQueryPlanNode plan;

            try {
                var planValue = query.EvaluateToConstant(context, null);
                if (planValue == null)
                {
                    throw new InvalidOperationException();
                }

                if (!(planValue.Type is QueryType))
                {
                    throw new InvalidOperationException();
                }

                plan = ((SqlQueryObject)planValue.Value).QueryPlan;
            } catch (QueryException) {
                throw;
            } catch (SecurityException) {
                throw;
            } catch (Exception ex) {
                throw new InvalidOperationException(String.Format("Could not delete from table '{0}': unable to form the delete set.", tableName), ex);
            }

            var deleteSet = plan.Evaluate(context);

            return(context.DeleteFrom(tableName, deleteSet, limit));
        }