Skip to content

Handle enum's #7

Open
Open
@dazinator

Description

@dazinator

MapToList fails when coming accross enum properties.

Could handle them something like:

    var val = dr.GetValue(colMapping[prop.Name.ToLower()].ColumnOrdinal.Value);
    if(prop.PropertyType.IsEnum)
    {
             prop.SetValue(obj, val == DBNull.Value ? null : Enum.ToObject(prop.PropertyType, (int)val));
     }
     else
     {
              prop.SetValue(obj, val == DBNull.Value ? null : val);
      }

The above isn't really finished, as it doesn't handle null correcty,- i.e should map DbNull only to nullable enums.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions