public enum Hands
{
Left,
Right
}
public class HandPropertyHandler : IPropertyHandler<string, Hands?>
{
public Hands? Get(string input, ClassProperty property)
{
// Transformation back to class
return Hands.Left;
}
public string Set(Hands? input, ClassProperty property)
{
// Transformation towards the database
return Hands.Left.ToString();
}
}
public class Person
{
public int Id { get; set; }
[PropertyHandler(typeof(HandPropertyHandler))]
public Hands? Hand { get; set; }
}
Person newPerson= new Person();
int id = connection.Insert<Person, int>(newPerson);
result in Exception
'No coercion operator is defined between types 'System.String' and 'System.Nullable`1[RepodbTest.Hands]'.'
result in Exception
'No coercion operator is defined between types 'System.String' and 'System.Nullable`1[RepodbTest.Hands]'.'