public static IListQueryBuilder DefaultLimit(this Csg.ListQuery.Sql.IListQueryBuilder builder, int limit) { return(builder.BeforeApply((config) => { if (config.QueryDefinition.Limit <= 0) { config.QueryDefinition.Limit = limit; } })); }
public static IListQueryBuilder MaxLimit(this Csg.ListQuery.Sql.IListQueryBuilder builder, int maxLimit, bool silent = true) { return(builder.BeforeApply((config) => { if (config.QueryDefinition.Limit > maxLimit && !silent) { throw new InvalidOperationException($"The value specified for limit {config.QueryDefinition.Limit} is greater than the maximum allowed value of {maxLimit}."); } config.QueryDefinition.Limit = Math.Min(maxLimit, config.QueryDefinition.Limit); })); }