mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-14 10:47:08 -07:00
Added PetaPoco
This commit is contained in:
parent
6355d5ada1
commit
63f6899894
43 changed files with 29270 additions and 85 deletions
33
NzbDrone.Core/Datastore/CustomeMapper.cs
Normal file
33
NzbDrone.Core/Datastore/CustomeMapper.cs
Normal file
|
@ -0,0 +1,33 @@
|
|||
using System;
|
||||
using PetaPoco;
|
||||
|
||||
namespace NzbDrone.Core.Datastore
|
||||
{
|
||||
public class CustomeMapper : DefaultMapper
|
||||
{
|
||||
public override Func<object, object> GetFromDbConverter(DestinationInfo destinationInfo, Type SourceType)
|
||||
{
|
||||
|
||||
if ((SourceType == typeof(Int32) || SourceType == typeof(Int64)) && destinationInfo.Type.IsGenericType && destinationInfo.Type.GetGenericTypeDefinition() == typeof(Nullable<>))
|
||||
{
|
||||
// If it is NULLABLE, then get the underlying type. eg if "Nullable<int>" then this will return just "int"
|
||||
if (destinationInfo.Type.GetGenericArguments()[0].IsEnum)
|
||||
{
|
||||
return delegate(object s)
|
||||
{
|
||||
int value;
|
||||
Int32.TryParse(s.ToString(), out value);
|
||||
if (value == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return (Nullable<DayOfWeek>)value;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return base.GetFromDbConverter(destinationInfo, SourceType);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue