mirror of
https://github.com/Sonarr/Sonarr
synced 2024-12-28 10:48:46 +00:00
fc641baab3
added support for embedded documents.
37 lines
No EOL
757 B
C#
37 lines
No EOL
757 B
C#
using System;
|
|
using Marr.Data.Converters;
|
|
using Marr.Data.Mapping;
|
|
|
|
namespace NzbDrone.Core.Datastore
|
|
{
|
|
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;
|
|
}
|
|
}
|
|
} |