EFCore-FluentStoredProcedure icon indicating copy to clipboard operation
EFCore-FluentStoredProcedure copied to clipboard

Handle enum's

Open dazinator opened this issue 6 years ago • 0 comments

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.

dazinator avatar Nov 06 '17 18:11 dazinator