DapperLib/Dapper · error · ArgumentNullException
columnName
Error message
columnName
What it means
SimpleMemberMap's property overload (columnName, PropertyInfo) rejects a null columnName with ArgumentNullException(nameof(columnName)). The column name is stored as the canonical DataReader column key and cannot be null. A null property is also rejected on the same line.
Source
Thrown at Dapper/SimpleMemberMap.cs:18
using System;
using System.Reflection;
namespace Dapper
{
/// <summary>
/// Represents simple member map for one of target parameter or property or field to source DataReader column
/// </summary>
internal sealed class SimpleMemberMap : SqlMapper.IMemberMap
{
/// <summary>
/// Creates instance for simple property mapping
/// </summary>
/// <param name="columnName">DataReader column name</param>
/// <param name="property">Target property</param>
public SimpleMemberMap(string columnName, PropertyInfo property)
{
ColumnName = columnName ?? throw new ArgumentNullException(nameof(columnName));
Property = property ?? throw new ArgumentNullException(nameof(property));
}
/// <summary>
/// Creates instance for simple field mapping
/// </summary>
/// <param name="columnName">DataReader column name</param>
/// <param name="field">Target property</param>
public SimpleMemberMap(string columnName, FieldInfo field)
{
ColumnName = columnName ?? throw new ArgumentNullException(nameof(columnName));
Field = field ?? throw new ArgumentNullException(nameof(field));
}
/// <summary>
/// Creates instance for simple constructor parameter mapping
/// </summary>
/// <param name="columnName">DataReader column name</param>
View on GitHub (pinned to 72a54c475f)
Solutions
- When building a SimpleMemberMap, always pass the concrete reader column name; null-check before constructing.
- If authoring a custom ITypeMap, return null from GetMember/GetConstructorParameter rather than a map with a null column name.
Example fix
// before (custom map) return new SimpleMemberMap(null, prop); // after return columnName is null ? null : new SimpleMemberMap(columnName, prop);
Defensive patterns
Strategy: validation
Validate before calling
if (columnName is null) return null; // for custom ITypeMap return new SimpleMemberMap(columnName, property);
Prevention
- In custom ITypeMap implementations, return null instead of building a map with a null column name.
- Validate reader column names before constructing member maps.
When it happens
Trigger: Constructing new SimpleMemberMap(null, prop); Dapper internals creating a member map where the column name resolved to null (e.g. a reader column with a null/empty name, or a custom ITypeMap returning a map with a null column).
Common situations: A custom ITypeMap implementation returning SimpleMemberMap with a null columnName; a DataReader whose schema returned a null column name (rare malformed provider result).
Related errors
AI-assisted analysis of DapperLib/Dapper@72a54c475f (2026-08-13).
Data as JSON: /api/errors/2dbbaeea3bc390cd.
Report an issue: GitHub.