Skip to content

Bug PropertyHandler for Nullable Enum #402

@sellig

Description

@sellig
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]'.'

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdeployedFeature or bug is deployed at the current releasereviewThe changes are under or being reviewed

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions