{"record":{"id":"186cd23730e164e1","repo":"aspnetboilerplate/aspnetboilerplate","slug":"nameof-parameters-cannot-be-null-186cd2","errorCode":null,"errorMessage":"{nameof(parameters)} cannot be null.","messagePattern":"(.+?) cannot be null\\.","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Abp.Dapper/Dapper-Extensions/Sql/SqlGenerator.cs","lineNumber":142,"sourceCode":"        }\n\n        var innerSql = new StringBuilder(Select(classMap, predicate, sort, parameters, colsToSelect, includedProperties));\n\n        var partitionBy = GetPartitionBy();\n\n        return Configuration.Dialect.GetPagingSql(innerSql.ToString(), page, resultsPerPage, parameters, partitionBy);\n    }\n\n    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)\n    {\n        if (sort?.Any() != true)\n        {\n            throw new ArgumentNullException(nameof(Sort), $\"{nameof(Sort)} cannot be null or empty.\");\n        }\n\n        if (parameters == null)\n        {\n            throw new ArgumentNullException(nameof(parameters), $\"{nameof(parameters)} cannot be null.\");\n        }\n\n        var innerSql = new StringBuilder($\"SELECT {BuildSelectColumns(classMap, colsToSelect, includedProperties)} FROM {GetTables(classMap, parameters, includedProperties)}\");\n\n        if (predicate != null)\n        {\n            innerSql.Append(\" WHERE \")\n                .Append(predicate.GetSql(this, parameters));\n        }\n\n        var orderBy = sort.Select(s => GetColumnName(classMap, s.PropertyName, false) + (s.Ascending ? \" ASC\" : \" DESC\")).AppendStrings();\n        innerSql.Append(\" ORDER BY \").Append(orderBy);\n\n        return Configuration.Dialect.GetSetSql(innerSql.ToString(), firstResult, maxResults, parameters);\n    }\n\n    public virtual string Count(IClassMapper classMap, IPredicate predicate, IDictionary<string, object> parameters, IList<IReferenceMap> includedProperties = null)\n    {","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/aspnetboilerplate/aspnetboilerplate/blob/2323c13a152aa0ebfb37af3830f687d7f5b53795/src/Abp.Dapper/Dapper-Extensions/Sql/SqlGenerator.cs#L124-L160","documentation":"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)}').","triggerScenarios":"Calling SelectSet with valid sort but parameters = null.","commonSituations":"Raw SqlGenerator usage in custom repositories where the dictionary was never created; ported code from libraries whose overloads defaulted parameters.","solutions":["Pass new Dictionary<string, object>() when no parameters exist","Ensure the repository wrapper always instantiates the parameter bag","Add an early validation in your calling code with a clear error message"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (parameters == null) parameters = new Dictionary<string, object>();","typeGuard":null,"tryCatchPattern":"try { sql = generator.SelectSet(classMap, predicate, sort, first, max, parameters, colsToSelect); } catch (ArgumentNullException ex) when (ex.ParamName == \"parameters\") { /* normalize and retry */ }","preventionTips":["Never pass null collections into SqlGenerator; use empty collections","Add a thin wrapper API that fills in safe defaults"],"tags":["csharp","argument-validation","dapper","null-argument"],"backgroundTag":"null-argument","analyzedSha":"2323c13a152aa0ebfb37af3830f687d7f5b53795","analyzedAt":"2026-09-08T08:00:50.638Z","contentChangedAt":"2026-09-08T08:00:50.638Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}