aspnetboilerplate/aspnetboilerplate · error · ArgumentNullException

cannot be null.

Error message

{nameof(parameters)} cannot be null.

What it means

The parameters-null guard inside SqlGenerator.SelectSet. After the sort check, it requires a non-null parameters dictionary since predicate and sort processing may add bind variables; null throws ArgumentNullException for 'parameters' (message shows literal '{nameof(parameters)}').

Solutions

  1. Pass new Dictionary<string, object>() when no parameters exist
  2. Ensure the repository wrapper always instantiates the parameter bag
  3. Add an early validation in your calling code with a clear error message
Defensive patterns

Strategy: validation

Validate before calling

if (parameters == null) parameters = new Dictionary<string, object>();

Try / catch

try { sql = generator.SelectSet(classMap, predicate, sort, first, max, parameters, colsToSelect); } catch (ArgumentNullException ex) when (ex.ParamName == "parameters") { /* normalize and retry */ }

Prevention

When it happens

Trigger: Calling SelectSet with valid sort but parameters = null.

Common situations: Raw SqlGenerator usage in custom repositories where the dictionary was never created; ported code from libraries whose overloads defaulted parameters.

Related errors


AI-assisted analysis of aspnetboilerplate/aspnetboilerplate@2323c13a15 (2026-09-08). Data as JSON: /api/errors/186cd23730e164e1. Report an issue: GitHub.

Appendix: source

Thrown at src/Abp.Dapper/Dapper-Extensions/Sql/SqlGenerator.cs:142

        }

        var innerSql = new StringBuilder(Select(classMap, predicate, sort, parameters, colsToSelect, includedProperties));

        var partitionBy = GetPartitionBy();

        return Configuration.Dialect.GetPagingSql(innerSql.ToString(), page, resultsPerPage, parameters, partitionBy);
    }

    public virtual string SelectSet(IClassMapper classMap, IPredicate predicate, IList<ISort> sort, int firstResult, int maxResults, IDictionary<string, object> parameters, IList<IProjection> colsToSelect, IList<IReferenceMap> includedProperties = null)
    {
        if (sort?.Any() != true)
        {
            throw new ArgumentNullException(nameof(Sort), $"{nameof(Sort)} cannot be null or empty.");
        }

        if (parameters == null)
        {
            throw new ArgumentNullException(nameof(parameters), $"{nameof(parameters)} cannot be null.");
        }

        var innerSql = new StringBuilder($"SELECT {BuildSelectColumns(classMap, colsToSelect, includedProperties)} FROM {GetTables(classMap, parameters, includedProperties)}");

        if (predicate != null)
        {
            innerSql.Append(" WHERE ")
                .Append(predicate.GetSql(this, parameters));
        }

        var orderBy = sort.Select(s => GetColumnName(classMap, s.PropertyName, false) + (s.Ascending ? " ASC" : " DESC")).AppendStrings();
        innerSql.Append(" ORDER BY ").Append(orderBy);

        return Configuration.Dialect.GetSetSql(innerSql.ToString(), firstResult, maxResults, parameters);
    }

    public virtual string Count(IClassMapper classMap, IPredicate predicate, IDictionary<string, object> parameters, IList<IReferenceMap> includedProperties = null)
    {

View on GitHub (pinned to 2323c13a15)