1
0
Fork 0
mirror of https://github.com/Radarr/Radarr synced 2024-12-26 09:49:00 +00:00
Radarr/NzbDrone.Core/Datastore/Converters/EnumIntConverter.cs

37 lines
768 B
C#
Raw Normal View History

using System;
using Marr.Data.Converters;
using Marr.Data.Mapping;
2013-04-23 00:44:47 +00:00
namespace NzbDrone.Core.Datastore.Converters
{
public class EnumIntConverter : IConverter
{
public Type DbType
{
get
{
return typeof(int);
}
}
public object FromDB(ColumnMap map, object dbValue)
{
if (dbValue != null && dbValue != DBNull.Value)
{
return Enum.ToObject(map.FieldType, (Int64)dbValue);
}
return null;
}
public object ToDB(object clrValue)
{
if (clrValue != null)
{
return (int)clrValue;
}
return DBNull.Value;
}
}
}