Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle enum's #7

Open
dazinator opened this issue Nov 6, 2017 · 0 comments
Open

Handle enum's #7

dazinator opened this issue Nov 6, 2017 · 0 comments

Comments

@dazinator
Copy link
Contributor

dazinator commented Nov 6, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant