-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Closed
Description
We're currently using a custom type map like this:
internal class RemoveSpacesFromColumnNames : SqlMapper.ITypeMap
{
private readonly Type _type;
public RemoveSpacesFromColumnNames(Type type)
{
_type = type;
}
public ConstructorInfo FindConstructor(string[] names, Type[] types) =>
_type.GetConstructors().Single();
public ConstructorInfo? FindExplicitConstructor() => null;
public SqlMapper.IMemberMap? GetConstructorParameter(ConstructorInfo constructor, string columnName)
{
var nameWithoutSpaces = columnName.Replace(" ", "");
var parameter = constructor.GetParameters().FirstOrDefault(x => x.Name == nameWithoutSpaces);
return parameter == null ? null : new CustomParameterMap(columnName, parameter);
}
public SqlMapper.IMemberMap? GetMember(string columnName) => null;
}where we'd added the nullable reference annotations ourselves. (Hopefully this code doesn't look too crazy :)
However when updating to dapper 2.1.4 this code now fails to compile since GetConstructorParameter is expected to return SqlMapper.IMemberMap instead of SqlMapper.IMemberMap?.
In SqlMapper.GenerateDeserializerFromMap it seems like the output of this method is checked for null in the same way that GetMember is, so I guess returning null is probably valid here?
Metadata
Metadata
Assignees
Labels
No labels