Dapper icon indicating copy to clipboard operation
Dapper copied to clipboard

CustomPropertyTypeMap propertySelector does now allow null

Open uitmaurik opened this issue 2 years ago • 0 comments

The constructor of CustomPropertyTypeMap accepts two parameters. The propertySelector parameter is of type Func<Type, string, PropertyInfo>. If I understand correctly this means that the function must always return a PropertyInfo. Returning null is not allowed due to the project setting <Nullable>enable</Nullable>. As the method public SqlMapper.IMemberMap? GetMember(string columnName) is the only method that uses the propertySelector and is already capable of handling a null return value, I would like to request to modify the constructor to (so changing the return type of the function from PropertyInfo to PropertyInfo?):

public CustomPropertyTypeMap(Type type, Func<Type, string, PropertyInfo?> propertySelector)

and of course the variable to:

private readonly Func<Type, string, PropertyInfo?> _propertySelector;

uitmaurik avatar Dec 08 '23 09:12 uitmaurik